[Insight-users] jpg display

David Gobbi dgobbi at atamai.com
Wed Jul 12 17:28:24 EDT 2006


Hi Liu,

To display the image with its original colors, you have to cast
it to "unsigned char" before setting it as an input to vtkTexture.
The best class to use for this if vtkImageShiftScale:

vtkImageShiftScale *caster = vtkImageShiftScale::New();
caster->SetOutputScalarTypeToUnsignedChar();
caster->SetShift(0.0);
caster->SetScale(1.0);  // might need to set to 255.0
caster->SetInput(connector->GetOutput());

Texture->SetInput(caster->GetOutput());

The "Scale" value of 255.0 will be needed if you use
float values between 0.0 and 1.0 to represent red, green
and blue since "unsigned char" data uses values
between 0 and 255.

 - David




liu jianfei wrote:
> Hi, everyone
>
>   I'm using ITK filters to process some colon JPG files and VTK
> filters to display the results. itk::ImageToVTKImageFilter was
> employed to convert ITK data into the vtk structedpoints. The results
> of ITK image were considered as the texture and attacted with the
> vtkplanesource to display the final image. Here are a part of codes.
>
>    FloatImageConnectorType::Pointer connector =
> FloatImageConnectorType::New();
> connector->SetInput(image);
> connector->Update();
> Texture->SetInput(connector->GetOutput());
>
>  However, the result image looks like lack of color information.
>
>  If the jpg file is directly loaded using vtkJPEGReader, the result
> is correct.
>
>   vtkJPEGReader *JPEGReader = vtkJPEGReader::New();
> JPEGReader->SetFileName("/Users/ljf/program/Registration/data/OCvideo001.jpg"); 
>
> Texture->SetInput(JPEGReader->GetOutput());
>
>
> But I want to use ITK filters to do some image processing for my colon
> data, and the results could be automatically updataed and visualized.
> Can anyone tell me what's wrong with my pipeline between ITK and VTK?
> Thanks a lot.



More information about the Insight-users mailing list