Hi Abayiz,<br><br>Since you declared the image type to be:<br><br> typedef itk::Image<VectorType, Dimension> VectorImageType;<br><br>where "VectorType" is the pixel type of the image,<br><br>Then SetPixel() method of the image is expecting <br>
that you pass to it the parameters of type<br><br> image->SetPixel( IndexType, VectorType ); <br><br><br>But in your code, <br>you are passing a VariableLenghtVector type<br>as second argument.<br><br>So, what you need to do is <br>
to replace that for loop with simply:<br><br> VectorType unitVector;<br> unitVector[0] = 1.0;<br> unitVector[1] = 0.0;<br> unitVector[2] = 0.0;<br><br> image->FillBuffer( unitVector );<br><br><br>BTW, just for the record, the call<br>
<br> image->SetPixel( index, unitVector );<br><br>should also work, once you use the right<br>type for the unitVector variable.<br><br><br><br> Luis<br><br><br><br>-----------------------------------------------<br>
<div class="gmail_quote">On Thu, May 17, 2012 at 3:22 PM, Abayiz <span dir="ltr"><<a href="mailto:abayiz@yahoo.com" target="_blank">abayiz@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div>Hello,</div><div><br></div><div>I am trying to build a unit vector field, my code is as follows:</div><div><br></div><div>************************************</div>
<div> typedef itk::Vector<float, Dimension > VectorType;<br></div><div> typedef itk::Image<VectorType,Dimension> VectorImageType;</div><div> typedef itk::ImageRegionConstIterator< VectorImageType > NeighborhoodIterator;<br>
</div><div><br></div><div> VectorImageType::Pointer image = VectorImageType::New();<br>
image->SetRegions(vec_region);<br> image->SetSpacing(vec_spacing_image);<br> image->SetOrigin(vector_origin_image);<br> image->SetDirection(vec_direction_image);<br> image->SetNumberOfComponentsPerPixel(3);<br>
image->Allocate(); </div><div><br></div><div> VectorImageType::IndexType vec_start;<br> vec_start[0] = 0;<br> vec_start[1] = 0;<br> vec_start[2] = 0;<br></div><div><br></div><div> typedef itk::VariableLengthVector<double> VariableVectorType;<br>
VariableVectorType variableLengthVector;<br> variableLengthVector.SetSize(2);<br> variableLengthVector[0] = 1.0;<br> variableLengthVector[1] = 0.0;<br> variableLengthVector[2] = 0.0;</div><div><br></div><div> NeighborhoodIterator vec_it(image, image->GetLargestPossibleRegion());<br>
<br> for (vec_it_i.GoToBegin();
!vec_it_i.IsAtEnd(); ++vec_it_i)<br> {<br><br> image->SetPixel(vec_start, variableLengthVector); <br><br> }</div><div><br></div><div>************************************<br></div><div>Then I got an error, saying that "image" does not have a function for "SetPixel". Is there some one can help me?? How should I build a unit vector?<br>
</div><div>Thanks in advance. <br></div><div><br></div><div>Regards</div><span class="HOEnZb"><font color="#888888"><div>Abayiz<br></div><div><br></div><div></div></font></span></div></div><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<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>