[vtkusers] [Fwd: raw slices - single file - visualize problem]
    anast.jm at pg.com 
    anast.jm at pg.com
       
    Fri Feb 20 15:06:30 EST 2004
    
    
  
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 ElementType = MET_UCHAR however so at least one f them got it right (-;  ....thats why you are 
seeing 4 images in one....john
Christos Panagiotou <C.Panagiotou at cs.ucl.ac.uk>
Sent by: vtkusers-admin at vtk.org
02/20/2004 02:08 AM
 
        To:     1__VTK POST <vtkusers at vtk.org>
        cc:     (bcc: John Anast-JM/PGI)
        Subject:        [vtkusers] [Fwd: raw slices - single file - visualize problem]
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();
}
-----------------------------------------------------------
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040220/8b5af24e/attachment.htm>
    
    
More information about the vtkusers
mailing list