[Insight-users] compare images

John Drozd john.drozd at gmail.com
Fri Aug 3 16:35:01 EDT 2012


Hi,

I use the "diff image1 image2" command in linux, where image1 and
image2 are the names of the two image files.  That way it also checks
the header information.

It works for binary images and says it they're different, but does not
display the different lines as it does for text files.

John

On 8/3/12, Gerenrot, Mikhail <mikhail.gerenrot at stryker.com> wrote:
> 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.
>
>


More information about the Insight-users mailing list