[vtkusers] vtkImageData doesnt get Colored.

David Gobbi dgobbi at irus.rri.ca
Tue Jan 15 23:02:00 EST 2002


Hi Jason,

After you pass the image through vtkImageMapToColors, the
range of the RGB image is [0:255] so you need to use

                       imgMapper.SetColorWindow(255.0);
                       imgMapper.SetColorLevel(127.5);

to make it display properly.

Also note that in the vtkLookupTable you should use
                 LUT1.SetAlphaRange(1.0,1.0);
i.e. make the image completely opaque, this makes no difference
because the vtkImageMapper ignores the alpha value but it
is good practice because e.g. vtkTexture _does_ use the alpha.

I would even go as far as recommending that you don't use alpha
at all:
                 mapToRGBA1.SetOutputFormatToRGB();

 - David

--
  David Gobbi, MSc                       dgobbi at irus.rri.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Wed, 16 Jan 2002, Rodrigues, Jason (MED) wrote:

>
>
>
>         Hello all,
>                I am expeirnceing a strange problem at this moment. I have a
> vtkImageData object that contains pixel values ranging from 0 - 2500. I want
> to color code these values by setting different HSV values of LookUpTable.
> But that doenst happen at all. instead the image appears to be completely
> balck. further analysis of the pixels at locations X and Y would give me the
> original pixel values. (i.e 0-2500)  Can  anybody suggest the possible
> solution for the same?
> What are the alternatives to display the image using colors in a vtkRenderer
> via the pipeline of vtkImageMapper?
> I am sending a small piece of code below.
>
>
>                 vtkLookupTable LUT1 = new vtkLookupTable();
> 		   LUT1.SetTableRange(0,2500);
> 		   LUT1.SetSaturationRange(0.0,1.0);
> 		   LUT1.SetHueRange(0.0, 1.0);
> 		   LUT1.SetValueRange(0.0, 1.0);
> 		   LUT1.SetAlphaRange(0.0,1.0);
> 		   LUT1.Build();
>               vtkImageMapToColors mapToRGBA1 = new vtkImageMapToColors();
> 		mapToRGBA1.SetInput(imagedata);
> 		mapToRGBA1.SetOutputFormatToRGBA();
> 		mapToRGBA1.SetLookupTable(LUT1);
>
>                vtkImageCast cast1 =new vtkImageCast ();
> 		cast1.SetInput(mapToRGBA1.GetOutput());
> 		cast1.SetOutputScalarType( 5 );
> 		imagedata= cast1.GetOutput();
>                         imagedata.update();
>
>               imgMapper = new vtkImageMapper();
>                        imgMapper.SetInput(imagedata);
>                        imgMapper.SetColorWindow(2500);
>                        imgMapper.SetColorLevel(1250);
>                        imgMapper.SetZSlice(sb.getValue());
>
>
>             vtkActor2D actor = new vtkActor2D();
>                        actor.SetMapper(imgMapper);
>
>             vtkRenderer ren=panel1.getRenderer();
>                         ren.AddActor2D(actor);
>                         ren.Render();
>
>
>
> "THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
> ADDRESSEE and may contain confidential and privileged information.
> If the reader of this message is not the intended recipient,
> you are notified that any dissemination, distribution or copy of this
> communication is strictly Prohibited.
> If you have received this message by error, please notify us
> immediately, return the original mail to the sender and delete the
> message from your system."
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list