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