[vtkusers] How to read and display a JPEG image
Elvis Dowson
elvis.dowson at mac.com
Fri Oct 3 12:43:01 EDT 2008
Hi,
I found out that I had to set the ColorWindow and ColorLevel
to make the image appear as follows:
// Map 2D image file
imageMapper = vtkImageMapper::New();
imageMapper->SetInput(imageReader->GetOutput());
imageMapper->SetColorWindow(255);
imageMapper->SetColorLevel(127.5);
Could someone please tell me why this is required? What is the effect
of Color Window and Color Level on the image? I know that when it
comes to medical imaging, with DICOM images there is a concept of
window level and window width, used primarily for selectively
displaying bone and tissue, but I don't know why you have Color Window
and Color Level here for an image mapper.
Best regards,
Elvis Dowson
On Oct 3, 2008, at 8:02 PM, Elvis Dowson wrote:
> Hi,
> I took a look at vtkActor2D, etc. The documentation is not
> that helpful in figuring out what is going wrong. I think I have
> used all the required methods in vtkActor2D, if you look at the code
> below, such as using a JPEG reader, using an image mapper to prepare
> the interface with vtkActor2D. But it still doesn't work.
>
> For the moment, I don't want to use vtkTextureActor2D, since I don't
> want to mess around with scaling or altering the geometric
> properties of the 2D map that I am importing. The underlying image
> is a 2D map, so I want it to be preserved with it's original
> properties.
>
> Could someone help me get this to work with vtkActor2D ?
>
> Best regards,
>
> Elvis
>
> // Declare object instance variables
> vtkJPEGReader* imageReader;
> vtkImageMapper* imageMapper;
> vtkActor2D* mapActor;
>
> // Initialize objects
> imageReader = NULL;
> imageMapper = NULL;
> mapActor = NULL;
>
> // Read 2D image file
> imageReader = vtkJPEGReader::New();
> imageReader->SetFileName("/Users/elvis/Project/C4I/Source/cxx/
> vtkRendererMultiLayer/Dubai.A2003285.0655.250m.jpg");
> imageReader->Update();
>
> // Map 2D image file
> imageMapper = vtkImageMapper::New();
> imageMapper->SetInput(imageReader->GetOutput());
>
> // Actor in scene
> mapActor = vtkActor2D::New();
> mapActor->SetLayerNumber(0);
> mapActor->SetMapper(imageMapper);
>
> // Add Actor to renderer
> ren->AddActor2D(mapActor);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081003/73d74d3b/attachment.htm>
More information about the vtkusers
mailing list