[vtkusers] vtkImagePlaneWidget not shows image on plane

Karthik Krishnan karthik.krishnan at kitware.com
Thu Sep 16 08:00:37 EDT 2010


Did you try running Examples/GUI/Tcl/ImagePlaneWidget.tcl . It does pretty
much what you are trying to do.

Also note that the widget itself has a lookup table that it can pass the
data through. This is much more efficient than what you are trying, since it
does the window-level mapping just on the intersected slice, instead of the
whole volume as you are performing.

--
karthik

On Wed, Sep 15, 2010 at 11:07 PM, Héber de Padua Sousa <hebersousa at gmail.com
> wrote:

> It is possible showing slice's grayscale texture instead just white color?
>
> 2010/9/14 Héber de Padua Sousa <hebersousa at gmail.com>
>
> 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;
>> }
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> 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/20100916/68e57395/attachment.htm>


More information about the vtkusers mailing list