Hi Eduardo, Value() cannot be used with a VectorImage. Try doing:<div><br></div><div>itk::VariableLengthVector<float> vec = oo.Get();</div><div>float value = vec[2]; </div><div><br></div><div>or</div><div><br></div>
<div>float vec = oo.Get()[2];</div><div><br><div><br><div class="gmail_quote">On Thu, Mar 24, 2011 at 12:13 PM, Eduardo Suarez-Santana <span dir="ltr"><<a href="mailto:esuarez@itccanarias.org">esuarez@itccanarias.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I'd like to assign a component of a pixel of a VectorImage. I'm trying<br>
to use the Value() method from an iterator without success. It works<br>
with Image type, but I get a compiler error with VectorImage.<br>
<br>
How can I assign just one component of a VectorImage?<br>
<br>
Thanks,<br>
-Eduardo<br>
<br>
<br>
++++++++++++++++ testVector.cxx<br>
#include "itkImageRegionIterator.h"<br>
#include "itkVectorImage.h"<br>
<br>
int main(int argc, char *argv[] )<br>
{<br>
<br>
typedef itk::VectorImage<float,2> ImageType;<br>
//typedef itk::Image<float,2> ImageType;<br>
<br>
ImageType::Pointer image = ImageType::New();<br>
<br>
ImageType::SizeType regionSize;<br>
regionSize[0] = 5;<br>
regionSize[1] = 4;<br>
<br>
ImageType::IndexType regionIndex;<br>
regionIndex[0] = 0;<br>
regionIndex[1] = 0;<br>
<br>
ImageType::RegionType region;<br>
region.SetSize(regionSize);<br>
region.SetIndex(regionIndex);<br>
<br>
// comment next line to try with itk::Image<br>
image->SetVectorLength( 5 );<br>
image->SetRegions( region );<br>
image->Allocate();<br>
<br>
itk::ImageRegionIterator<ImageType> oo( image, region );<br>
<br>
oo.GoToBegin();<br>
while( !oo.IsAtEnd() )<br>
{<br>
// what I would like to do is something like<br>
//oo.Value()[2]=29837.0;<br>
<br>
// next line prints a compiler error when using VectorImage<br>
oo.Value();<br>
++oo;<br>
}<br>
<br>
}<br>
<br>
+++++++++++++++ CMakeLists.txt<br>
cmake_minimum_required(VERSION 2.6)<br>
<br>
find_package(ITK)<br>
if(ITK_FOUND)<br>
include(${ITK_USE_FILE})<br>
else(ITK_FOUND)<br>
message(FATAL_ERROR "Please set ITK_DIR.")<br>
endif(ITK_FOUND)<br>
<br>
project(testVector)<br>
<br>
add_executable(testVector testVector.cxx)<br>
target_link_libraries(testVector ${ITK_LIBRARIES})<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<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.html" target="_blank">http://www.kitware.com/products/protraining.html</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>
</blockquote></div><br></div></div>