<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks for the suggestions Jerome.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I was simply passing the smart pointer to a writer:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> vtkBMPWriter* writer = vtkBMPWriter::New();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> writer->SetInput(here is the returned smart pointer);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> writer->SetFileName(filename);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> writer->Write();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> writer->Delete();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>It turns out that placing resample->Update(); before setting
up the input of colorMap does fix the problem, although I’m 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. I’m 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 …<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>KB<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Jérôme
[mailto:jerome.velut@gmail.com] <br>
<b>Sent:</b> Wednesday, December 02, 2009 4:51 PM<br>
<b>To:</b> bulkmailaddress@gmail.com<br>
<b>Cc:</b> vtkusers@vtk.org<br>
<b>Subject:</b> Re: [vtkusers] resample issue<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'>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.<br>
<br>
HTH<br>
Jerome<o:p></o:p></p>
<div>
<p class=MsoNormal>2009/12/2 Jérôme <<a href="mailto:jerome.velut@gmail.com">jerome.velut@gmail.com</a>><o:p></o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'>Hi,<br>
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. <br>
<br>
Jerome<o:p></o:p></p>
<div>
<p class=MsoNormal>2009/12/2 Karl <<a href="mailto:bulkmailaddress@gmail.com"
target="_blank">bulkmailaddress@gmail.com</a>><o:p></o:p></p>
<div>
<div>
<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;
margin-left:4.8pt;margin-right:0in'>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Hi,<br>
<br>
I am attempting unsuccessfully to use vtkImageResample to change the spacing<br>
of an image.<br>
I have a 3D volume that is being resliced with a vtkImagePlaneWidget. I
am<br>
then requesting the slice.<br>
The code works fine until I add this filter, can anyone tell me what I am<br>
doing wrong.<br>
<br>
Thanks<br>
KB<br>
<br>
Code before filter is added (executes with no problem):<br>
_________________________________________<br>
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData(QString<br>
sliceName)<br>
{<br>
// use vtkImageMapToColors to map to 8-bit for
output<br>
vtkImageMapToColors* colorMap =
vtkImageMapToColors::New();<br>
colorMap->PassAlphaToOutputOff();<br>
colorMap->SetActiveComponent(0);<br>
colorMap->SetOutputFormatToLuminance();<br>
colorMap->SetInput(planeWidget->GetResliceOutput());<br>
colorMap->SetLookupTable(planeWidget->GetLookupTable());<br>
<br>
vtkSmartPointer<vtkImageData> slice =
colorMap->GetOutput();<br>
<br>
colorMap->Delete();<br>
return slice;<br>
}<br>
<br>
<br>
<br>
Code after filter is added:<br>
__________________________________________<br>
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData()<br>
{<br>
// resample to isotropic spacing<br>
vtkImageResample* resample =
vtkImageResample::New();<br>
resample->SetInput(planeWidget->GetResliceOutput());<br>
resample->SetDimensionality(2);<br>
resample->SetAxisOutputSpacing(0,1);<br>
resample->SetAxisOutputSpacing(1,1);<br>
<br>
// use vtkImageMapToColors to map to 8-bit for
output<br>
vtkImageMapToColors* colorMap =
vtkImageMapToColors::New();<br>
colorMap->PassAlphaToOutputOff();<br>
colorMap->SetActiveComponent(0);<br>
colorMap->SetOutputFormatToLuminance();<br>
colorMap->SetInput(resample->GetOutput());<br>
colorMap->SetLookupTable(planeWidget->GetLookupTable());<br>
<br>
vtkSmartPointer<vtkImageData> slice =
colorMap->GetOutput();<br>
<br>
resample->Delete();<br>
colorMap->Delete();<br>
return slice;<br>
}<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a
href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a
href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>