[Insight-users] How to access a value from the index array?

David Doria daviddoria at gmail.com
Tue Oct 23 07:31:18 EDT 2012


On Tue, Oct 23, 2012 at 1:20 AM, D, Yamini <Yamini.D at philips.com> wrote:
> Hi,
> Thank you for the reply, I did the changes but I have a basic doubt in defining "id" for the index.
>
> ///code
> InputImageType::IndexType index;
> std::vector<InputImageType::IndexType> indices;
> int i,j;
> for (i=0;i<size_x;i++){
>         for (j=0;j<size_y; j++){
>                 index[0]=i; // x-values
>                 index[1]=j; // y-values
> indices.push_back(index);
>
> InputImageType::PixelType pixelValue = image->GetPixel(index);
> if(pixelValue==255)
> cout<<index[0]<<"    " << index[1]<<endl;
>         }
> }
>
> /////error
> itk::ImageRegionIterator<InputImageType> id;
>
> for(id=0; id< size; id+=5)
> {
>          indices[id];
>
>          cout<< "indices " << indices <<endl;
> }

Please keep the discussion on the mailing list. Also, please post the
smallest possible compilable code that demonstrates the problem, as
well as explain exactly what the problem is. See this:
http://www.vtk.org/Wiki/VTK/MinimalExample for a basic guide to doing
this.

Also, please look the examples on the wiki. For example, this one:
http://www.itk.org/Wiki/ITK/Examples/Iterators/ImageRegionConstIterator
shows you how to use a region iterator. You have not told the iterator
which image or region to operate on.

David


More information about the Insight-users mailing list