[vtkusers] 3D modeling .. some more help plzzzz ...

Florent.Chandelier at USherbrooke.ca Florent.Chandelier at USherbrooke.ca
Wed Sep 29 12:03:53 EDT 2004


I add the code that makes me mad .... but I've removed from the code 
everything that is unusefull for the 3D rendering .
Check the code below the mail :

>Well, I know that bone tissue is in between 100 and 220 considering the file I
>have. In fact I have bmp file so it is not raw acquisition but my all lab work
>with bmp though ..... whatever, I make a threshold after reading all the slides
>using the "inbetween" option so I set bone to 255 and tissue to 100.
>Once this is done, I create a volume with that, that is correct and where my
>bone appears in white (255) and where non-bone tissue appeared in light gray
>(100) which is correct.
>Then, from this volume I want to render a 3D volume using triangles, so first I
>extract contour and then apply triangles. This works fine for bone tissue, as I
>extract contour of 255 and apply triangles, but if I extract non-bone tissue
>using the value 100 in the setValue of vtkcontour.. then I got nothing in my
>rendering ..... here is my prob .... I hope I'm clear enough ... or tell me and
>I try to explain it in a better way.
>
>So another answer to your mail may be, I don't have range value for bone or
>whatever ... but like a binary file 255 for bone and 100 for non-bone tissue .
>
>thx for helping me
>
>florent
>  
>

void main( int argc, char *argv[] )
{
    // read bmp file
  vtkBMPReader *imagein=vtkBMPReader::New();
  imagein->SetFilePrefix ("slices"); // name of the files to read
  imagein->SetDataExtent(0, 255, 0, 255,0,5);

  // thresholding and "binarising" the images

  int TissueLow;
  int TissueHigh;

  TissueLow=100;
  TissueHigh=220;

  vtkImageThreshold *binimg=vtkImageThreshold::New();
  binimg->SetInput(imagein->GetOutput());   
  binimg->ThresholdBetween(TissueLow,TissueHigh);
  binimg->SetInValue(255); // bone value -> bone will appeared bright
  binimg->SetOutValue(100); // tissue value -> tissue will be light-gray

  
  // rendering
  vtkRenderer *aRenderer = vtkRenderer::New();
  vtkRenderWindow *renWinf = vtkRenderWindow::New();
  renWinf->AddRenderer(aRenderer);
  vtkRenderWindowInteractor *irenf = vtkRenderWindowInteractor::New();
  irenf->SetRenderWindow(renWinf);


  vtkContourFilter *Extractor = vtkContourFilter::New();
  Extractor->SetInput((vtkDataSet *) binimg->GetOutput());
  Extractor->SetValue(0,100);
 

 
  vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
  Mapper->SetInput(Extractor->GetOutput());
  Mapper->ScalarVisibilityOff();


 
  vtkActor *result = vtkActor::New();
  result->SetMapper(Mapper);
  aRenderer->AddActor(result);
  aRenderer->SetBackground(1,1,1);


  // Interact with the data at 3 frames per second
  irenf->SetDesiredUpdateRate(1.0);
  irenf->SetStillUpdateRate(0.001);
  irenf->Start();


  // Set the size of the render window (expressed in pixels).
  renWinf->SetSize(300, 300);
  renWinf->Render();
  // Start the Interactor
  irenf->Start();

  

  // Clean up
  renWinf->Delete();
  aRenderer->Delete();
  irenf->Delete();
  imagein->Delete();
  result->Delete();
  Mapper->Delete();
  Extractor->Delete();

 
 
}



More information about the vtkusers mailing list