[Insight-users] 'and/or' operation between images

iamrndm b arindam.osu.cse at gmail.com
Tue Aug 9 12:06:52 EDT 2011


hi all ,
I am writing  a simple filter where I need to be able to do 'and' 'or'
operation between 2 binary images , I am reading in to images into 'image'
and iterating through using a very simple

//
template<class TImage>
void OilPaintingImageFilter<TImage>
::ThreadedGenerateData(const typename Superclass::OutputImageRegionType&
outputRegionForThread,
int threadId)
{
  cerr <<" thread id " <<  threadId << endl;

  typename TImage::ConstPointer input1 = this->GetInput(0);
   typename TImage::ConstPointer input2 = this->GetInput(1);
  typename TImage::Pointer output = this->GetOutput();


  itk::ImageRegionIterator<TImage> outputIterator(output,
outputRegionForThread);
  itk::ImageRegionConstIterator<TImage> inputIterator1(input1,
outputRegionForThread);
  itk::ImageRegionConstIterator<TImage> inputIterator2(input2,
outputRegionForThread);

  while(!outputIterator.IsAtEnd())
    {
   // if(inputIterator1.GetIndex()[0] == inputIterator2.GetIndex()[1])
   // if(inputIterator1.GetIndex()[0] == inputIterator2.GetIndex()[0])
    if(inputIterator1.Get() == inputIterator2.Get())
      {
      outputIterator.Set(255);
      }
    else
      {
      outputIterator.Set(128);
      }

    ++inputIterator1;
    ++inputIterator2;
    ++outputIterator;
    }
}
}
//

My question is is there and easier way  of reading the entire image into a
VECTOR and just do a 'and/or'  operation on the entire vector.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110809/46b27b49/attachment.htm>


More information about the Insight-users mailing list