[vtkusers] Convert grayscale image to rgb
Milan Vidakovic
milan.vidakovic at tp.rs
Sat May 31 12:24:29 EDT 2014
Did try adding range, but it made no difference. The images are displayed
on vtkImageViewer2, if that plays a part.
Thank you.
On Sat, May 31, 2014 at 6:11 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> You might have to tell scalarsToColors what the range of your
> data is, before you use the colorMapper:
>
> scalarsToColors->SetRange(imageData->GetScalarRange());
>
>
> On Sat, May 31, 2014 at 9:58 AM, Milan Vidakovic <milan.vidakovic at tp.rs>
> wrote:
> > Thank you for a quick response. I did try it, and the scalar space does
> > increase to rgb, but my output is completely black. My vtkScalarsToColors
> > might be lacking something. The code is:
> >
> > vtkSmartPointer<vtkScalarsToColors> scalarsToColors =
> > vtkSmartPointer<vtkScalarsToColors>::New();
> >
> > vtkSmartPointer<vtkImageMapToColors> colorMapper =
> > vtkSmartPointer<vtkImageMapToColors>::New();
> > firstColorMapper->SetOutputFormatToRGB();
> > firstColorMapper->SetInputData(myImageVtkImageData);
> > firstColorMapper->SetLookupTable( scalarsToColors );
> >
> >
> > On Sat, May 31, 2014 at 5:44 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
> >>
> >> Use vtkImageMapToColors, here is a python example of
> >> how to set it up:
> >>
> >> rgbConverter = vtkImageMapToColors()
> >> rgbConverter.SetOutputFormatToRGB()
> >> rgbConverter.SetLookupTable(vtkScalarsToColors())
> >>
> >> The "vtkScalarsToColors" object describes how the
> >> mapping of scalars to colors is done. By default, it just
> >> replicates the scalar into the r, g, and b components.
> >>
> >> David
> >>
> >>
> >> On Sat, May 31, 2014 at 9:21 AM, Milan Vidakovic <milan.vidakovic at tp.rs
> >
> >> wrote:
> >> > I have a number of single-scalar grayscale vtkImageData objects that
> >> > would
> >> > need to convert to rgb. Is there a way to perform this transformation
> >> > without loosing the grayscale information? Even a change from
> grayscale
> >> > to
> >> > mono-color would do the trick.
> >> >
> >> > Thank you!
> >> > Milan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140531/b8efdbed/attachment.html>
More information about the vtkusers
mailing list