[vtkusers] vtkImagePlaneWidget not shows image on plane

Héber de Padua Sousa hebersousa at gmail.com
Tue Sep 14 18:50:58 EDT 2010


Hi!
I need help, please!
I'm working with vtkImagePlaneWidget, but the image is not showing on the
plane.
Where the plane intersect the volume It shows the color white Instead
slice's grayscale texture.
What is the problem?
thanks
this is the code:

 #include "vtkImageData.h"
 #include "vtkImageViewer2.h"
 #include "vtkRenderWindowInteractor.h"
 #include "vtkDICOMImageReader.h"
 #include "vtkVolumeRayCastMapper.h"
#include "vtkRenderWindowInteractor.h"

 #include "vtkVolumeTextureMapper2D.h"
 #include "vtkVolumeTextureMapper3D.h"
#include "vtkVolumeProperty.h"
#include "vtkColorTransferFunction.h"
#include "vtkPiecewiseFunction.h"
#include <vtkImageShiftScale.h>
#include "vtkVolumeRayCastMIPFunction.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkCamera.h"
#include "vtkImagePlaneWidget.h"
#include "vtkSmartPointer.h"
#include "vtkLookupTable.h"

 #include "vtkRenderer.h"
#include "vtkRenderWindow.h"

int main()
{

vtkDICOMImageReader *reader = vtkDICOMImageReader :: New();
  reader-> SetDirectoryName("C:/volumes/PulmaoExtraido/25fatias");

  reader->Update();

    double range[2];
         (reader->GetOutput())->GetScalarRange(range);

    double shiftValue = 0;
if(range[0] < 0) shiftValue =(-1)*range[0];
 vtkImageShiftScale *shiftScale = vtkImageShiftScale::New();
shiftScale->SetInput(reader->GetOutput());
 shiftScale->SetScale(1);
shiftScale->SetShift(shiftValue);
shiftScale->ClampOverflowOn();
 shiftScale->SetOutputScalarTypeToUnsignedShort();


vtkRenderer *aRenderer = vtkRenderer::New();

vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);

vtkLookupTable* table1 = vtkLookupTable::New();
table1->SetNumberOfTableValues(256);
table1->Build();
double r=0;
double g=0;
double b=0;
int indice;
table1->SetTableValue(0,r/255,g/255,b/255,1.0);
for(int i=1;i<256;i++) {

     r++;
     g++;
     b++;
     indice=i;
     table1->SetTableValue(indice,r/255,g/255,b/255,1.0);
}
table1->SetTableRange(0,1000);
table1->SetAlphaRange(1.0,1.0);

vtkImagePlaneWidget *widget = vtkImagePlaneWidget::New();
 widget->SetLookupTable(table1);
widget->SetInteractor(iren);
widget->TextureVisibilityOn();
 widget->EnabledOn();
widget->SetInput(shiftScale->GetOutput());
widget->SetPlaneOrientationToZAxes();
 widget->PlaceWidget (0, 200, 0, 200, 0, 25);

   aRenderer->SetBackground(0,0.3,0.3);

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

reader->Delete();
 aRenderer->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100914/a5ea32af/attachment.htm>


More information about the vtkusers mailing list