[vtkusers] resample issue
Karl
bulkmailaddress at gmail.com
Wed Dec 2 22:27:54 EST 2009
Thanks for the suggestions Jerome.
I was simply passing the smart pointer to a writer:
vtkBMPWriter* writer = vtkBMPWriter::New();
writer->SetInput(here is the returned smart pointer);
writer->SetFileName(filename);
writer->Write();
writer->Delete();
It turns out that placing resample->Update(); before setting up the input of
colorMap does fix the problem, although Im not sure why. This is necessary
both if SetInput or SetInputConnection is used to connect the filters. If I
use a different filter (e.g. vtkExtractVOI) then this Update call is not
necessary. Im not sure why this is, as this behavior seems inconsistent
with what I have come to expect from vtk, but it seems to be working now
KB
From: Jérôme [mailto:jerome.velut at gmail.com]
Sent: Wednesday, December 02, 2009 4:51 PM
To: bulkmailaddress at gmail.com
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] resample issue
Oops, I just saw that vtkImageMapToColors is a vtkImageAlgorithm, so the
pipeline should work. The problem may come from how you use the returned
pointer: you have to update your pipeline before using the imagedata.
HTH
Jerome
2009/12/2 Jérôme <jerome.velut at gmail.com>
Hi,
You should be more precise about your problem. I guess you missed a
resample->Update() before setting the input of colorMap, but not for sure.
Jerome
2009/12/2 Karl <bulkmailaddress at gmail.com>
Hi,
I am attempting unsuccessfully to use vtkImageResample to change the spacing
of an image.
I have a 3D volume that is being resliced with a vtkImagePlaneWidget. I am
then requesting the slice.
The code works fine until I add this filter, can anyone tell me what I am
doing wrong.
Thanks
KB
Code before filter is added (executes with no problem):
_________________________________________
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData(QString
sliceName)
{
// use vtkImageMapToColors to map to 8-bit for output
vtkImageMapToColors* colorMap = vtkImageMapToColors::New();
colorMap->PassAlphaToOutputOff();
colorMap->SetActiveComponent(0);
colorMap->SetOutputFormatToLuminance();
colorMap->SetInput(planeWidget->GetResliceOutput());
colorMap->SetLookupTable(planeWidget->GetLookupTable());
vtkSmartPointer<vtkImageData> slice = colorMap->GetOutput();
colorMap->Delete();
return slice;
}
Code after filter is added:
__________________________________________
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData()
{
// resample to isotropic spacing
vtkImageResample* resample = vtkImageResample::New();
resample->SetInput(planeWidget->GetResliceOutput());
resample->SetDimensionality(2);
resample->SetAxisOutputSpacing(0,1);
resample->SetAxisOutputSpacing(1,1);
// use vtkImageMapToColors to map to 8-bit for output
vtkImageMapToColors* colorMap = vtkImageMapToColors::New();
colorMap->PassAlphaToOutputOff();
colorMap->SetActiveComponent(0);
colorMap->SetOutputFormatToLuminance();
colorMap->SetInput(resample->GetOutput());
colorMap->SetLookupTable(planeWidget->GetLookupTable());
vtkSmartPointer<vtkImageData> slice = colorMap->GetOutput();
resample->Delete();
colorMap->Delete();
return slice;
}
_______________________________________________
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
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091202/6afa491f/attachment.htm>
More information about the vtkusers
mailing list