[vtkusers] vtkImagePlaneWidget not shows image on plane

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


I use reader->GetScalarRange() because before I was using raycastmap that
accept only unsigned values.the getScalarRange is for get the smaller value
of image and to do a rescale of the values the volume.The image dicom that I
am opennig range from -1000 to 500, after the rescale the range is from 0 to
up. But this is not the problem. I do'nt need more the vtkImageShiftScale .
I am not using raycastmap.



 2010/9/14 Jim Peterson <jimcp at cox.net>

> HEber,
> you appear to be discounting all scalar values below zero. What is the
> actual range of values returned from reader->GetScalarRange()?
>
> Jim
>
>
> Héber de Padua Sousa wrote:
>
>> 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
>>
>>
>
>


-- 
>> Héber de Padua Sousa
/~heber
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100914/0085f49b/attachment.htm>


More information about the vtkusers mailing list