[vtkusers] BUG: vtkImageMapToColors does not output with input spacing and origin
Mengda Wu
wumengda at gmail.com
Wed Jan 13 10:44:40 EST 2016
Has anyone tested this bug?
Thanks!
On Wed, Jan 6, 2016 at 4:22 PM, Mengda Wu <wumengda at gmail.com> wrote:
> Hi Vtkusers,
>
> I found a bug in vtkImageMapToColors. It does not output with input
> spacing and origin. It sets the spacing to [1,1,1] and origin to [0,0,0]. I
> am using VTK 6.2 but I believe it happens also in VTK 7.0. Can you fix
> this? Here is a test program and a sample image (input.mha) and its
> output(input-colormap.mha):
>
> vtkSmartPointer<vtkMetaImageReader> inputReader =
> vtkSmartPointer<vtkMetaImageReader>::New();
> inputReader->SetFileName(argv[1]);
> try
> {
> inputReader->Update();
> }
> catch(...)
> {
> std::cerr << "Error occurs when reading " << argv[1] << std::endl;
> return EXIT_FAILURE;
> }
>
> vtkSmartPointer<vtkLookupTable> lookupTable =
> vtkSmartPointer<vtkLookupTable>::New();
> lookupTable->SetTableRange(0.0, 255.0);
> lookupTable->SetNumberOfTableValues(256);
> lookupTable->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
> for(vtkIdType i=1; i<256; i++)
> lookupTable->SetTableValue(i, 1.0, 0.0, 0.0, 0.4);
> lookupTable->Build();
> vtkSmartPointer<vtkImageMapToColors> imageColor =
> vtkSmartPointer<vtkImageMapToColors>::New();
> imageColor->SetInputConnection(inputReader->GetOutputPort());
> imageColor->SetOutputFormatToRGBA();
> imageColor->SetLookupTable(lookupTable);
>
> vtkSmartPointer< vtkMetaImageWriter > writer = vtkSmartPointer<
> vtkMetaImageWriter >::New();
> writer->SetFileName(argv[2]);
> writer->SetInputConnection(imageColor->GetOutputPort());
> try
> {
> writer->Write();
> }
> catch(...)
> {
> std::cerr << "Error occurs when writing " << argv[2] << std::endl;
> return EXIT_FAILURE;
> }
>
> Thanks,
> Mengda
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160113/dd3537df/attachment.html>
More information about the vtkusers
mailing list