<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
It seems that you're calculating the sine function a lot of times. Pre-computing this to a table and then using this table in the loop might speed up your program significantly.<br><br>&gt; Date: Fri, 4 Jan 2008 23:04:19 -0500<br>&gt; From: francois.bertel@kitware.com<br>&gt; To: vtkusers@vtk.org<br>&gt; Subject: Re: [vtkusers] Newbie question about VTK speed<br>&gt; <br>&gt; I don't know but I see that you're doing computation in your loop. Try<br>&gt; to time this overhead first by commenting out viewer-&gt;Render().<br>&gt; <br>&gt; On 1/4/08, Hughes, Mike &lt;msh@cmrl.wustl.edu&gt; wrote:<br>&gt; &gt; Thanks for the really fast answer.<br>&gt; &gt;<br>&gt; &gt; I checked my NVIDIA openGL settings and it seems that the vertical blank<br>&gt; &gt; option was not set (correct me if I'm wrong, I've attached a screen shot of<br>&gt; &gt; the dialog box I'm refering to).<br>&gt; &gt;<br>&gt; &gt; I'd be glad to check any other suggestions you might have.<br>&gt; &gt;<br>&gt; &gt; Regards,<br>&gt; &gt;<br>&gt; &gt; Mike<br>&gt; &gt;<br>&gt; &gt; PS<br>&gt; &gt; Do you have any idea of what sort of frame rates should I expect?<br>&gt; &gt;<br>&gt; &gt; -----Original Message-----<br>&gt; &gt; From: Francois Bertel [mailto:francois.bertel@kitware.com]<br>&gt; &gt; Sent: Friday, January 04, 2008 9:18 PM<br>&gt; &gt; To: Hughes, Mike<br>&gt; &gt; Subject: Re: [vtkusers] Newbie question about VTK speed<br>&gt; &gt;<br>&gt; &gt; Hi Mike,<br>&gt; &gt;<br>&gt; &gt; 180/2.57=70. It seems you have vertical blank sync option on with a monitor<br>&gt; &gt; working at 70Hz. If you want to benchmark the framerate, you have to set it<br>&gt; &gt; off. Run nvidia-settings,  Uncheck "Sync to VBlank"  in OpenGL Settings. or<br>&gt; &gt; in your shell , set the following environment variable to 0 (see any nvidia<br>&gt; &gt; documentation):<br>&gt; &gt; $export __GL_SYNC_TO_VBLANK=0<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On 1/4/08, Hughes, Mike &lt;msh@cmrl.wustl.edu&gt; wrote:<br>&gt; &gt; &gt; I've just started using VTK to do image processing.  I wrote the<br>&gt; &gt; &gt; program below (Vol-r5) to test the frame rate for writing different<br>&gt; &gt; &gt; images to the screen of my computer (Dual dual-core Xeons with and<br>&gt; &gt; &gt; VCQFX1500-PCIE-PB Nvidia 1500 video adapter running Ubuntu linux with<br>&gt; &gt; &gt; working OpenGL drivers installed).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; When I run the program I get the following output:<br>&gt; &gt; &gt;         $ ./Vol-r5<br>&gt; &gt; &gt;         dt= 2.57 for: 180 frames<br>&gt; &gt; &gt; Where dt is the execution time to compute and display 180 frames.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; This seems to be astoundingly slow for a machine with working OpenGL<br>&gt; &gt; &gt; drivers installed.  I've explored the VTK class hierarchy and it seems<br>&gt; &gt; &gt; that if OpenGL is available it should be automatically used.  I hope<br>&gt; &gt; &gt; that I'm mistaken on this.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Is there a way to display frames at a higher rate?  I would ultmately<br>&gt; &gt; &gt; like to display 512x512 images (which takes about 9 sec with the program<br>&gt; &gt; below).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Vol-r5.cpp listing....<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; #include "vtkImageWriter.h"<br>&gt; &gt; &gt; #include "vtkImageReader.h"<br>&gt; &gt; &gt; #include "vtkPointData.h"<br>&gt; &gt; &gt; #include "vtkRenderer.h"<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; //#include "vtkRenderWindow.h"<br>&gt; &gt; &gt; //#include &lt;vtkXOpenGLRenderWindow.h&gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; #include "vtkImageViewer.h"<br>&gt; &gt; &gt; #include "vtkRenderWindowInteractor.h"<br>&gt; &gt; &gt; #include "vtkStructuredPoints.h"<br>&gt; &gt; &gt; #include "vtkFloatArray.h"<br>&gt; &gt; &gt; #include "vtkContourFilter.h"<br>&gt; &gt; &gt; #include "vtkPolyDataMapper.h"<br>&gt; &gt; &gt; #include "vtkActor.h"<br>&gt; &gt; &gt; #include "vtkImageCast.h"<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; #include &lt;time.h&gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; const float Pi=3.14159;<br>&gt; &gt; &gt; const int NumberOfFrames=180;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; int main ()<br>&gt; &gt; &gt; {<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;         float sp, z, y, x, s, dx,dy,scale;<br>&gt; &gt; &gt;         int i, j, k, ii, kOffset, jOffset, offset,h;<br>&gt; &gt; &gt;         int xSize=255;<br>&gt; &gt; &gt;         int ySize=255;<br>&gt; &gt; &gt;         int zSize=0;<br>&gt; &gt; &gt;         clock_t start, stop;<br>&gt; &gt; &gt;         dx=1.0/((double)xSize);<br>&gt; &gt; &gt;         dy=1.0/((double)ySize);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;         vtkImageData *image = vtkImageData::New();<br>&gt; &gt; &gt;         image-&gt;SetDimensions(xSize+1,ySize+1,zSize+1);<br>&gt; &gt; &gt;         image-&gt;SetScalarTypeToFloat();<br>&gt; &gt; &gt;         image-&gt;AllocateScalars();<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;         float *ptr = static_cast&lt;float*&gt;(image-&gt;GetScalarPointer());<br>&gt; &gt; &gt;         float *startptr;<br>&gt; &gt; &gt;         startptr = ptr;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;         vtkImageViewer *viewer = vtkImageViewer::New();<br>&gt; &gt; &gt;         viewer-&gt;SetInput(image);<br>&gt; &gt; &gt;         viewer-&gt;SetColorWindow(20.0);<br>&gt; &gt; &gt;         viewer-&gt;SetColorLevel(0.0);<br>&gt; &gt; &gt;         start=clock();<br>&gt; &gt; &gt;         for(scale=1.0,k=0;k&lt;NumberOfFrames;k++,scale+=0.1)<br>&gt; &gt; &gt;         {<br>&gt; &gt; &gt;                 ptr=startptr;<br>&gt; &gt; &gt;                 for(x=0.0,i=0;i&lt;xSize+1;i++,x+=dx)<br>&gt; &gt; &gt;                         for(y=0.0,j=0;j&lt;ySize+1;j++,y+=dy)<br>&gt; &gt; &gt;                                 *ptr++ = scale*sin(8.0*Pi*x)*sin(8.0*Pi*y);<br>&gt; &gt; &gt;                 viewer-&gt;Render();<br>&gt; &gt; &gt;         }<br>&gt; &gt; &gt;         stop=clock();<br>&gt; &gt; &gt;         cout &lt;&lt; " dt= " &lt;&lt;<br>&gt; &gt; &gt; ((double)(stop-start))/((double)CLOCKS_PER_SEC) &lt;&lt; " for: " &lt;&lt;<br>&gt; &gt; &gt; NumberOfFrames &lt;&lt; " frames" &lt;&lt; endl;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;         viewer-&gt;Delete();<br>&gt; &gt; &gt;         image-&gt;Delete();<br>&gt; &gt; &gt;         // Clean up<br>&gt; &gt; &gt;         return 1;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; _______________________________________________<br>&gt; &gt; &gt; This is the private VTK discussion list.<br>&gt; &gt; &gt; Please keep messages on-topic. Check the FAQ at:<br>&gt; &gt; &gt; http://www.vtk.org/Wiki/VTK_FAQ Follow this link to subscribe/unsubscribe:<br>&gt; &gt; &gt; http://www.vtk.org/mailman/listinfo/vtkusers<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>&gt; &gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>&gt; &gt;                       | Clifton Park NY 12065, USA<br>&gt; &gt;<br>&gt; &gt;<br>&gt; <br>&gt; <br>&gt; -- <br>&gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>&gt;                       | Clifton Park NY 12065, USA<br>&gt; _______________________________________________<br>&gt; This is the private VTK discussion list. <br>&gt; Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; http://www.vtk.org/mailman/listinfo/vtkusers<br><br /><hr />Get the power of Windows + Web with the new Windows Live. <a href='http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_012008' target='_new'>Get it now!</a></body>
</html>