[vtkusers] vtkDICOMImageReader and vtkImageShiftScale

Francois Bertel francois.bertel at kitware.com
Tue Jun 23 20:26:08 EDT 2009


Hello,

SetOutputScalarType() just casts type for each element. It is not enough:
you have to use SetShift() and SetScale() as well.

http://www.vtk.org/doc/nightly/html/classvtkImageShiftScale.html

1. Get the range of your scalars:

reader->Update();
double range[2];
reader->GetOutput()->GetPointData()->GetScalars()->GetRange(range);

2. use it to set up the shift and scale

scale->SetShift(-range[0]);
scale->SetScale(VTK_UNSIGNED_SHORT_MAX/(range[1]-range[0]));
scale->SetOutputScalarTypeToUnsignedShort();

Regards.

On Tue, Jun 23, 2009 at 8:45 AM, Alex Duţu<alex.dutu at gmail.com> wrote:
> I got this working, seems like I had
> "VolumeMapper->SetInput(dicomReader->GetOutput());" line after
> VolumeMapper->SetInput(scale->GetOutput()); line.
>
> Now that everything renders I have another problem, all my volume is white,
> I guess that all the  scalars in the volume exceed unsigned short max limit
> so all my scalars are that value (65536), so that's why everything is white.
> I have used before vtkFixedPointRayCastVolumeMapper, and I didn't had this
> problem.
>
> How can I get the correct scaling so that the colors are rendered correctly?
>
> Best Regards,
> Alex
>
> On Tue, Jun 23, 2009 at 2:55 PM, Alex Duţu <alex.dutu at gmail.com> wrote:
>>
>> Hi everyone,
>>
>> I've seen that many of you had problems with volumeRayCastMapper because
>> it supports just unsigned char and unsigned short (vtkVolumeRayCastMapper
>> (025D0198): Cannot volume render data of type short, only unsigned char or
>> unsigned short.). I have the same problem so I used vtkImageShiftScale, but
>> the problem is still there. My code looks like this:
>>
>>>
>>>    vtkDICOMImageReader *dicomReader = vtkDICOMImageReader::New();
>>>     dicomReader->SetDirectoryName("D:/images/MANIX/CER-CT/ANGIO CT");
>>>     dicomReader->Update();
>>>
>>>     vtkImageShiftScale *scale = vtkImageShiftScale::New();
>>>     scale->SetInput(dicomReader->GetOutput());
>>>     scale->SetOutputScalarTypeToUnsignedShort();
>>>
>>>     vtkVolumeRayCastMapper *VolumeMapper =
>>> vtkVolumeRayCastMapper::New();
>>>     VolumeMapper->SetBlendModeToComposite();
>>>     VolumeMapper->SetInput(scale->GetOutput());
>>
>> Can anybody help me?
>>
>> Thanks in advance,
>> Alex
>
>
> _______________________________________________
> 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
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list