[Insight-users] compare images

Gerenrot, Mikhail mikhail.gerenrot at stryker.com
Fri Aug 3 16:21:34 EDT 2012


Hi Team,

We need to check if images are equal, and we wrote a method that uses iterators and compares pixels:
bool AreImagesEqual(const ImageType::Pointer & image1, const ImageType::Pointer & image2)
{
  itk::ImageSliceConstIteratorWithIndex<ImageType> it1( image1, image1->GetRequestedRegion() );
  itk::ImageSliceConstIteratorWithIndex<ImageType> it2( image2, image2->GetRequestedRegion() );

  PixelType p1;
  PixelType p2;

// loop starts
...
  p1 = it1.Get();
  p2 = it2.Get();
  if(p1 != p2)
  {
    return false;
  }
...
// loop ends
return true;
}

Is there any better way?
Any input will be greatly appreciated.

Thank you all in advance,

Your Mike Gerenrot
Stryker Corp.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120803/2ea479e9/attachment.htm>


More information about the Insight-users mailing list