<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1481657763314_3970" dir="ltr">Thanks, I've just tried that. It works in the sense that it only loads the block specified by the vtkImageClip, but then if I try to change blocks (when the slider goes out of range of the first block), it fails I believe because the vtkMetaImageReader has released its data. If I remove the line "reader->SetReleaseDataFlag(1);", then it is able to load different blocks, but doesn't save any memory, since now the vtkMetaImageReader is just keeping all the data in memory rather than releasing it. How can I allow the vtkMetaImageReader to release all data, but be able to load new data when needed? Here's the updated code:</div><div id="yui_3_16_0_ym19_1_1481657763314_3970" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4279">// load image data</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4280">vtkSmartPointer< vtkMetaImageReader> reader = vtkSmartPointer< vtkMetaImageReader>::New();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4281">reader->SetReleaseDataFlag(1);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4282">reader->SetFileName("test.mhd");</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4283">reader->Update();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4284">int *ext = reader->GetOutput()->GetExtent();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4285"><br id="yui_3_16_0_ym19_1_1481657763314_4286"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4287">// clip</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4288">int block_current = 0;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4289">int block_size = 100;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4290">clip = vtkSmartPointer<vtkImageClip>::New();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4291">clip->SetInputConnection(reader->GetOutputPort());</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4292">clip->SetOutputWholeExtent(ext[0], ext[1], ext[2], ext[3], block_current, block_current + block_size - 1);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4293">clip->ClipDataOn();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4294"><br id="yui_3_16_0_ym19_1_1481657763314_4295"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4296">// colormap</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4297">vtkSmartPointer< vtkLookupTable> lut = vtkSmartPointer< vtkLookupTable>::New();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4298">lut->SetNumberOfColors(256);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4299">lut->SetRange(0, 400);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4300">lut->Build();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4301">for (size_t i = 0; i < 256; i++)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4302"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1481657763314_4303"> </span>lut->SetTableValue(i, (double)i/256, (double)i/256, (double)i/256);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4304"><br id="yui_3_16_0_ym19_1_1481657763314_4305"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4306">vtkSmartPointer< vtkImageMapToColors> maptoc =</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4307"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1481657763314_4308"> </span>vtkSmartPointer< vtkImageMapToColors>::New();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4309">maptoc->SetLookupTable(lut);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4310">maptoc->SetInputConnection(clip->GetOutputPort());</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4311">maptoc->Update();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4312"><br id="yui_3_16_0_ym19_1_1481657763314_4313"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4314">// rendering</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4315">viewer = vtkSmartPointer< vtkImageViewer2>::New();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4316">viewer->SetInputConnection( maptoc->GetOutputPort());</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4317">viewer->SetRenderWindow( window->GetRenderWindow());</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4318">viewer->GetRenderer()-> ResetCamera();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_4319">viewer->Render();</div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1481657763314_3971"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1481657763314_3984" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1481657763314_3983"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1481657763314_3982"> <div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_3990"> <font size="2" face="Arial" id="yui_3_16_0_ym19_1_1481657763314_3989"> <hr size="1" id="yui_3_16_0_ym19_1_1481657763314_3991"> <b><span style="font-weight:bold;">From:</span></b> Dean Inglis <inglis.dl@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Mike Withascarf <mikewithascarf@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "vtkusers@vtk.org" <vtkusers@vtk.org><br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, December 13, 2016 12:32 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] streaming images<br> </font> </div> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1481657763314_3981"><br><div id="yiv0938610248"><div id="yui_3_16_0_ym19_1_1481657763314_3988"><div dir="ltr" id="yui_3_16_0_ym19_1_1481657763314_3987"><div id="yui_3_16_0_ym19_1_1481657763314_3986"><div id="yui_3_16_0_ym19_1_1481657763314_3985">Hi Mike,<br clear="none"><br clear="none"></div>not sure if this would work, but what about inserting vtkImageClip between your reader<br clear="none"></div><div id="yui_3_16_0_ym19_1_1481657763314_4023">and the windowlevel filter in your pipeline with ClipDataOn?<br clear="none"></div><div id="yui_3_16_0_ym19_1_1481657763314_4024"><br clear="none"></div>- Dean<br clear="none"><div id="yui_3_16_0_ym19_1_1481657763314_4025"><br clear="none"></div></div><div class="yiv0938610248gmail_extra" id="yui_3_16_0_ym19_1_1481657763314_4026"><br clear="none"><div class="yiv0938610248gmail_quote" id="yui_3_16_0_ym19_1_1481657763314_4027">On Tue, Dec 13, 2016 at 12:20 PM, Mike Withascarf via vtkusers <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>></span> wrote:<br clear="none"><blockquote class="yiv0938610248gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;" id="yui_3_16_0_ym19_1_1481657763314_4030"><div class="yiv0938610248yqt8488801330" id="yiv0938610248yqt53326"><div id="yui_3_16_0_ym19_1_1481657763314_4029"><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;" id="yui_3_16_0_ym19_1_1481657763314_4028"><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2527">I have a pipeline that takes 3D image data (slices of 2D images) and displays it with a vtkImageViewer2 (with a slider to move through the slices). My datasets can get huge, so I am looking for a way to only load part of the image into memory at a time as needed. I tried using vtkImageDataStreamer without success, though I have a feeling that's not for image viewing, but rather processing. How can I accomplish what I'm trying to do? Any help is appreciated! Here is my basic code for loading and displaying the data:</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2527"><br clear="none"></div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2698">// load image data</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2699">vtkSmartPointer< vtkMetaImageReader> reader = vtkSmartPointer< vtkMetaImageReader>::New();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2700">reader->SetReleaseDataFlag(1);</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2701">reader->SetFileName("test.mhd" );</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2702"><br clear="none" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2703"></div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2704">// colormap</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2705">vtkSmartPointer< vtkLookupTable> lut = vtkSmartPointer< vtkLookupTable>::New();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2706">lut->SetNumberOfColors(256);</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2707">lut->SetRange(0, 400);</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2708">lut->Build();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2709">for (size_t i = 0; i < 256; i++)</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2710"><span id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2711" style="white-space:pre-wrap;"> </span>lut->SetTableValue(i, (double)i/256, (double)i/256, (double)i/256);</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2712"><br clear="none" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2713"></div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2714">vtkSmartPointer< vtkImageMapToColors> maptoc =</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2715"><span id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2716" style="white-space:pre-wrap;"> </span>vtkSmartPointer< vtkImageMapToColors>::New();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2717">maptoc->SetLookupTable(lut);</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2718">maptoc->SetInputConnection( reader->GetOutputPort());</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2719">maptoc->Update();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2720"><br clear="none" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2721"></div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2722">// rendering</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2723">viewer = vtkSmartPointer< vtkImageViewer2>::New();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2724">viewer->SetInputConnection( maptoc->GetOutputPort());</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2725">viewer->SetRenderWindow( window->GetRenderWindow());</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2726">viewer->GetRenderer()-> ResetCamera();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2727">viewer->Render();</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2727"><br clear="none"></div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2727">// note that window is of type QVTKWidget</div><div dir="ltr" id="yiv0938610248m_-4447926095863083008yui_3_16_0_ym19_1_1481649367845_2727">// when the user changes slices, I call viewer->SetSlice</div></div></div></div><br clear="none">______________________________ _________________<br clear="none">
Powered by <a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br clear="none">
<br clear="none">
Visit other Kitware open-source projects at <a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/ opensource/opensource.html</a><br clear="none">
<br clear="none">
Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" shape="rect" target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_ FAQ</a><br clear="none">
<br clear="none">
Search the list archives at: <a rel="nofollow" shape="rect" target="_blank" href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q= vtkusers</a><br clear="none">
<br clear="none">
Follow this link to subscribe/unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/ mailman/listinfo/vtkusers</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div><br><br></div> </div> </div> </div></div></body></html>