[vtkusers] Emulating Matlab imagesc() function in VTK

Nicholas Kinar n.kinar at usask.ca
Wed Aug 11 13:55:05 EDT 2010


Hello,

I am wondering if there is a way in VTK to render the elements of a 2D 
array in a similar fashion to the Matlab imagesc() function.  Suppose 
that I have a 1000-by-1000 array M of values.  In Matlab, calling 
imagesc(M) will display a color-mapped image with the colors scaled to 
the maximum and minimum numbers in the image.  Using the following 
Matlab syntax will plot the 2D array with a colorbar:

imagesc(M);
colorbar;

Is there a similar way to do this in VTK?  (I am currently working with 
C++.)  In the past, I tried using vtkImageViewer2, but I remember that I 
was not successful.  What would be an example pipeline (from start to 
finish) that would allow me to plot a similar image in VTK?

Since I am writing a Finite-Difference Time-Domain (FDTD) simulation, I 
would like to progressively update the plot at each timestep so that the 
user of the program can view an animation of how the simulation 
progresses.  How would I dynamically update the plot at each timestep?

As an aside, I would like to see a similar example added to the VTK 
distribution or to the community wiki.  I believe that this would 
provide an incredible service to the scientific C++ community, since 
most imagesc-style plots have been produced using either Matlab or 
Matplotlib.

Nicholas



More information about the vtkusers mailing list