<div dir="ltr"><div>Regarding speed and the VTK imaging pipeline, you have to be careful about "streaming" capabilities of VTK, especially for 3D images.<br></div><div><br></div><div>"Streaming" means that for each filter (or reader or mapper) the VTK imaging pipeline has a settable UpdateExtent, which specifies a region of the image.  I.e. a filter can be requested to only operate on part of the image.  If you use obj2->SetInputConnection(obj1->GetOutputPort()), then "obj2" will control the UpdateExtent of "obj1".  In other words, the consumer of a filter's output controls the UpdateExtent of that filter.</div><div><br></div><div>Here's where this is important with respect to speed.  When you display a slice of an image, the mapper will request an UpdateExtent for the voxels in that slice.  The pipeline will forward this UpdateExtent all the way back along the pipeline, usually all the way to the reader.  So if the user is trying to scroll through the slices, this can cause the reader to re-execute for every single new slice.  Obviously this will be slow.  One way to avoid this is to call Update() on the reader before connecting the reader to the rest of the pipeline.  Calling Update() before the pipeline sets the UpdateExtent will cause the reader to read the entire volume into memory just once.  If it isn't possible to call Update() before connecting the reader to the pipeline, you can instead call UpdateWholeExtent() at any point after the pipeline is created.</div><div><br></div><div>In general, when you build an image pipeline in VTK, you can consider which parts of the pipeline are "static" (only need to be executed once) and which are "dynamic" (respond to user interaction).  After setting up the "static" part of the pipeline, call UpdateWholeExtent() on it.  You can go even further by connecting the "static" part of the pipeline to the "dynamic" part of the pipeline with SetInputData() instead of SetInputConnection().  This will ensure that pipeline requests are never forwarded from the "dynamic" part of the pipeline to the "static" part.</div><div><br></div><div>So, in summary: the default behavior of the VTK image display pipeline is to stream regions of the image rather than to execute the filters over the whole image.  In some situations this is good, but in other situations you'll want to override this behavior by either calling Update() yourself and/or by using SetInputData() instead of SetInputConnection().</div><div><br></div><div> - David</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 13, 2018 at 7:37 AM, Sankhesh Jhaveri <span dir="ltr"><<a href="mailto:sankhesh.jhaveri@kitware.com" target="_blank">sankhesh.jhaveri@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail-m_7655580657963984221markdown-here-wrapper" style="font-family:"Lucida Sans",Cantarell,Verdana,sans-serif;color:rgb(11,83,148)"><p style="margin:0px 0px 1.2em">I see. That makes sense since its a viewport and not a filter. Have you seen the <code style="font-size:0.95em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(218,218,218);background-color:rgb(232,232,232);border-radius:3px;display:inline">vtkImageResliceMapper</code> class. Perhaps try slicing with that instead of the <code style="font-size:0.95em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(218,218,218);background-color:rgb(232,232,232);border-radius:3px;display:inline">vtkImageResliceViewer</code>, to see if you get better performance.</p>
<div title="MDH:SSBzZWUuIFRoYXQgbWFrZXMgc2Vuc2Ugc2luY2UgaXRzIGEgdmlld3BvcnQgYW5kIG5vdCBhIGZp
bHRlci4gSGF2ZSB5b3Ugc2VlbiB0aGUgYHZ0a0ltYWdlUmVzbGljZU1hcHBlcmAgY2xhc3MuIFBl
cmhhcHMgdHJ5IHNsaWNpbmcgd2l0aCB0aGF0IGluc3RlYWQgb2YgdGhlIGB2dGtJbWFnZVJlc2xp
Y2VWaWV3ZXJgLCB0byBzZWUgaWYgeW91IGdldCBiZXR0ZXIgcGVyZm9ybWFuY2UuPGRpdj48ZGl2
PjxkaXY+PGJyPjwvZGl2PjwvZGl2PjwvZGl2Pg==" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px">​</div></div></div></blockquote></div></div></div>