[vtkusers] streaming images

Mike Withascarf mikewithascarf at yahoo.com
Tue Dec 13 14:42:47 EST 2016


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:
// load image datavtkSmartPointer< vtkMetaImageReader> reader = vtkSmartPointer< vtkMetaImageReader>::New();reader->SetReleaseDataFlag(1);reader->SetFileName("test.mhd");reader->Update();int *ext = reader->GetOutput()->GetExtent();
// clipint block_current = 0;int block_size = 100;clip = vtkSmartPointer<vtkImageClip>::New();clip->SetInputConnection(reader->GetOutputPort());clip->SetOutputWholeExtent(ext[0], ext[1], ext[2], ext[3], block_current, block_current + block_size - 1);clip->ClipDataOn();
// colormapvtkSmartPointer< vtkLookupTable> lut = vtkSmartPointer< vtkLookupTable>::New();lut->SetNumberOfColors(256);lut->SetRange(0, 400);lut->Build();for (size_t i = 0; i < 256; i++) lut->SetTableValue(i, (double)i/256, (double)i/256, (double)i/256);
vtkSmartPointer< vtkImageMapToColors> maptoc = vtkSmartPointer< vtkImageMapToColors>::New();maptoc->SetLookupTable(lut);maptoc->SetInputConnection(clip->GetOutputPort());maptoc->Update();
// renderingviewer = vtkSmartPointer< vtkImageViewer2>::New();viewer->SetInputConnection( maptoc->GetOutputPort());viewer->SetRenderWindow( window->GetRenderWindow());viewer->GetRenderer()-> ResetCamera();viewer->Render();

      From: Dean Inglis <inglis.dl at gmail.com>
 To: Mike Withascarf <mikewithascarf at yahoo.com> 
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
 Sent: Tuesday, December 13, 2016 12:32 PM
 Subject: Re: [vtkusers] streaming images
   
Hi Mike,

not sure if this would work, but what about inserting vtkImageClip between your reader
and the windowlevel filter in your pipeline with ClipDataOn?

- Dean


On Tue, Dec 13, 2016 at 12:20 PM, Mike Withascarf via vtkusers <vtkusers at vtk.org> wrote:

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:
// load image datavtkSmartPointer< vtkMetaImageReader> reader = vtkSmartPointer< vtkMetaImageReader>::New();reader->SetReleaseDataFlag(1);reader->SetFileName("test.mhd" );
// colormapvtkSmartPointer< vtkLookupTable> lut = vtkSmartPointer< vtkLookupTable>::New();lut->SetNumberOfColors(256);lut->SetRange(0, 400);lut->Build();for (size_t i = 0; i < 256; i++) lut->SetTableValue(i, (double)i/256, (double)i/256, (double)i/256);
vtkSmartPointer< vtkImageMapToColors> maptoc = vtkSmartPointer< vtkImageMapToColors>::New();maptoc->SetLookupTable(lut);maptoc->SetInputConnection( reader->GetOutputPort());maptoc->Update();
// renderingviewer = vtkSmartPointer< vtkImageViewer2>::New();viewer->SetInputConnection( maptoc->GetOutputPort());viewer->SetRenderWindow( window->GetRenderWindow());viewer->GetRenderer()-> ResetCamera();viewer->Render();
// note that window is of type QVTKWidget// when the user changes slices, I call viewer->SetSlice
______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_ FAQ

Search the list archives at: http://markmail.org/search/?q= vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/ mailman/listinfo/vtkusers





   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161213/536508b7/attachment.html>


More information about the vtkusers mailing list