[Insight-users] small modification to ImageRegistration1 example question

Michael G michaelguiliametti at hotmail.com
Mon, 16 Feb 2004 03:40:31 +0000


Oh thank you for pointing that out - I must have mistyped it - I now changed 
it so it set the y origin to 0.0 as well - but no result, still exception 
MeanSquaresImageToImageMetric(0CC20098): FixedImageRegion is empty !!



>From: a a <superpetzpetz at yahoo.com.sg>
>To: insight-users at itk.org
>Subject: RE: [Insight-users] small modification to ImageRegistration1 
>example question
>Date: Mon, 16 Feb 2004 11:16:28 +0800 (CST)
>
>hi,
>
>hmm, why did you set oringin[0] twice?
>    double origin[2];
>     origin[0] = 0.0;
>     origin[0] = 0.0;
>     fixedItkBuffer->SetOrigin( origin );
>     movedItkBuffer->SetOrigin( origin );
>
>
>Michael G <michaelguiliametti at hotmail.com> wrote:
>Hi Julien,
>
>Thank you very much for your response. With your suggestions I implemented
>the example in Image5.cxx. It certainly can write out files from buffers I
>create externally. I applied the same modification now to
>ImageRegistration01, it compiles fine but I always get a caught exception
>of:
>
>itk::ERROR: MeanSquaresImageToImageMetric(0CC20098): FixedImageRegion is
>empty
>
>as if my buffer was empty. But I'm sure that it's filled! It prints out to
>file in my modification from Image5. I included the relevant code below, 
>can
>anyone offer any pointers, it must be a silly mistake. Thank you all.
>
>// Code :
>typedef itk::ImportImageFilter< PixelType, Dimension > FixedBuffer;
>typedef itk::ImportImageFilter< PixelType, Dimension > MovedBuffer;
>
>FixedBuffer::Pointer fixedItkBuffer = FixedBuffer::New();
>MovedBuffer::Pointer movedItkBuffer = MovedBuffer::New();
>
>FixedBuffer::SizeType sizeFixed;
>sizeFixed[0] = width;
>sizeFixed[1] = height;
>MovedBuffer::SizeType sizeMoved;
>sizeMoved[0] = width;
>sizeMoved[1] = height;
>
>FixedBuffer::IndexType startFixed;
>startFixed.Fill(0);
>MovedBuffer::IndexType startMoved;
>startMoved.Fill(0);
>
>FixedBuffer::RegionType regionFixed;
>regionFixed.SetIndex ( startFixed );
>regionFixed.SetSize ( sizeFixed );
>fixedItkBuffer->SetRegion( regionFixed );
>MovedBuffer::RegionType regionMoved;
>regionMoved.SetIndex ( startMoved );
>regionMoved.SetSize ( sizeMoved );
>movedItkBuffer->SetRegion( regionMoved );
>
>double origin[2];
>origin[0] = 0.0;
>origin[0] = 0.0;
>fixedItkBuffer->SetOrigin( origin );
>movedItkBuffer->SetOrigin( origin );
>
>double spacing[2];
>spacing[0] = 1.0;
>spacing[1] = 1.0;
>fixedItkBuffer->SetSpacing( spacing );
>movedItkBuffer->SetSpacing( spacing );
>
>// create two dummy buffers
>unsigned int test_fix[65536];
>unsigned int test_mov[65536];
>for( int i = 0; i < 65536; i++)
>if( i < 30000)
>test_fix[i] = 65536;
>else
>test_fix[i] = 0;
>
>for( int i = 0; i < 65536; i++)
>if( i < 30000)
>test_mov[i] = 0;
>else
>test_mov[i] = 65536;
>
>// set my input buffers to use test_fix and test_mov above
>fixedItkBuffer->SetImportPointer( test_fix, 65536, false );
>movedItkBuffer->SetImportPointer( test_mov, 65536, false );
>
>// now the motion registration part should be reading from my buffers?
>// no errors if I use a file writer to print these buffers out to file!
>registration->SetFixedImage( fixedItkBuffer->GetOutput() );
>registration->SetMovingImage( movedItkBuffer->GetOutput() );
>
>
>
>
>
>
>
> >From: "Julien Jomier"
> >To: "'asdas sdfsafd'"
> >,
> >Subject: RE: [Insight-users] small modification to ImageRegistration1
> >example question
> >Date: Fri, 13 Feb 2004 16:50:58 -0500
> >
> >Hi,
> >
> >SetFixedImage() and SetMovingImage() are both expecting an itkImage as
> >argument.
> >
> >You can create two itkImages from your image buffers. Take a look at the
> >Section 4.1.7 "Importing Image Data from a Buffer" in the 
>itkSoftwareGuide.
> >(Examples/DataRepresentation/Image/Image5.cxx).
> >
> >Then you can do something like
> >
> >registration->SetFixedImage(fixedImage);
> >registration->SetMovingImage(movingImage);
> >
> >where fixedImage and movingImage are itk::Image
> >
> >Hope this helps,
> >
> >Julien
> >
> > > -----Original Message-----
> > > From: insight-users-admin at itk.org
> > > [mailto:insight-users-admin at itk.org] On Behalf Of asdas sdfsafd
> > > Sent: Friday, February 13, 2004 12:32 PM
> > > To: insight-users at itk.org
> > > Subject: [Insight-users] small modification to
> > > ImageRegistration1 example question
> > >
> > >
> > > Hello All,
> > >
> > > I was using the MotionRegistration example project and it
> > > works fine. I
> > > wanted to modify the way it reads in the fixed and moving
> > > image files if
> > > possible. The way it currently does it is:
> > >
> > > registration->SetFixedImage( fixedImageReader->GetOutput() );
> > > registration->SetMovingImage( movingImageReader->GetOutput() );
> > >
> > > I have two pointers to two unsigned int image buffers
> > > containing the pixel
> > > data - instead of using the fixedImageReader->GetOutput()
> > > method, how could
> > > I ask the itk code to take the data directly from my image
> > > buffers - is this
> > > possible?
> > >
> > > registration->SetFixedImage( pBuff1 );
> > > registration->SetMovingImage( pBuff2 );
> > >
> > > Thank you for your time.
> > >
> > > _________________________________________________________________
> > > Choose now from 4 levels of MSN Hotmail Extra Storage - no
> > > more account
> > > overload! http://click.atdmt.com/AVE/go/onm00200362ave/direct/01/
> > >
> > > _______________________________________________
> > > Insight-users mailing list
> > > Insight-users at itk.org
> > > http://www.itk.org/mailman/listinfo/insight-> users
> > >
> >
> >_______________________________________________
> >Insight-users mailing list
> >Insight-users at itk.org
> >http://www.itk.org/mailman/listinfo/insight-users
>
>_________________________________________________________________
>Find great local high-speed Internet access value at the MSN High-Speed
>Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
>  Y! Asia presents Lavalife
>- Get clicking with thousands of local singles today!

_________________________________________________________________
Find great local high-speed Internet access value at the MSN High-Speed 
Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/