[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>&nbsp;</DIV>
<DIV>hmm, why did you set oringin[0] twice?</DIV>
<DIV>&nbsp;&nbsp; double origin[2];<BR>&nbsp;&nbsp;&nbsp; origin[0] = 0.0;<BR>&nbsp;&nbsp;&nbsp; origin[0] = 0.0;<BR>&nbsp;&nbsp;&nbsp; fixedItkBuffer-&gt;SetOrigin( origin );<BR>&nbsp;&nbsp;&nbsp; movedItkBuffer-&gt;SetOrigin( origin );<BR><BR><BR><B><I>Michael G &lt;michaelguiliametti at hotmail.com&gt;</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&lt; PixelType, Dimension &gt; FixedBuffer;<BR>typedef itk::ImportImageFilter&lt; PixelType, Dimension &gt; 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-&gt;SetRegion( regionFixed );<BR>MovedBuffer::RegionType regionMoved;<BR>regionMoved.SetIndex ( startMoved );<BR>regionMoved.SetSize ( sizeMoved );<BR>movedItkBuffer-&gt;SetRegion( regionMoved );<BR><BR>double origin[2];<BR>origin[0] = 0.0;<BR>origin[0] = 0.0;<BR>fixedItkBuffer-&gt;SetOrigin( origin );<BR>movedItkBuffer-&gt;SetOrigin( origin );<BR><BR>double spacing[2];<BR>spacing[0] = 1.0;<BR>spacing[1] = 1.0;<BR>fixedItkBuffer-&gt;SetSpacing( spacing
 );<BR>movedItkBuffer-&gt;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 &lt; 65536; i++)<BR>if( i &lt; 30000)<BR>test_fix[i] = 65536;<BR>else<BR>test_fix[i] = 0;<BR><BR>for( int i = 0; i &lt; 65536; i++)<BR>if( i &lt; 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-&gt;SetImportPointer( test_fix, 65536, false );<BR>movedItkBuffer-&gt;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-&gt;SetFixedImage( fixedItkBuffer-&gt;GetOutput() );<BR>registration-&gt;SetMovingImage( movedItkBuffer-&gt;GetOutput() );<BR><BR><BR><BR><BR><BR><BR><BR>&gt;From: "Julien Jomier" <JJOMIER at CS.UNC.EDU><BR>&gt;To: "'asdas sdfsafd'"
 <BR>&gt;<MICHAELGUILIAMETTI at HOTMAIL.COM>,<INSIGHT-USERS at ITK.ORG><BR>&gt;Subject: RE: [Insight-users] small modification to ImageRegistration1 <BR>&gt;example question<BR>&gt;Date: Fri, 13 Feb 2004 16:50:58 -0500<BR>&gt;<BR>&gt;Hi,<BR>&gt;<BR>&gt;SetFixedImage() and SetMovingImage() are both expecting an itkImage as<BR>&gt;argument.<BR>&gt;<BR>&gt;You can create two itkImages from your image buffers. Take a look at the<BR>&gt;Section 4.1.7 "Importing Image Data from a Buffer" in the itkSoftwareGuide.<BR>&gt;(Examples/DataRepresentation/Image/Image5.cxx).<BR>&gt;<BR>&gt;Then you can do something like<BR>&gt;<BR>&gt;registration-&gt;SetFixedImage(fixedImage);<BR>&gt;registration-&gt;SetMovingImage(movingImage);<BR>&gt;<BR>&gt;where fixedImage and movingImage are itk::Image<UNSIGNED int,dimension><BR>&gt;<BR>&gt;Hope this helps,<BR>&gt;<BR>&gt;Julien<BR>&gt;<BR>&gt; &gt; -----Original Message-----<BR>&gt; &gt; From: insight-users-admin at itk.org<BR>&gt; &gt;
 [mailto:insight-users-admin at itk.org] On Behalf Of asdas sdfsafd<BR>&gt; &gt; Sent: Friday, February 13, 2004 12:32 PM<BR>&gt; &gt; To: insight-users at itk.org<BR>&gt; &gt; Subject: [Insight-users] small modification to<BR>&gt; &gt; ImageRegistration1 example question<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Hello All,<BR>&gt; &gt;<BR>&gt; &gt; I was using the MotionRegistration example project and it<BR>&gt; &gt; works fine. I<BR>&gt; &gt; wanted to modify the way it reads in the fixed and moving<BR>&gt; &gt; image files if<BR>&gt; &gt; possible. The way it currently does it is:<BR>&gt; &gt;<BR>&gt; &gt; registration-&gt;SetFixedImage( fixedImageReader-&gt;GetOutput() );<BR>&gt; &gt; registration-&gt;SetMovingImage( movingImageReader-&gt;GetOutput() );<BR>&gt; &gt;<BR>&gt; &gt; I have two pointers to two unsigned int image buffers<BR>&gt; &gt; containing the pixel<BR>&gt; &gt; data - instead of using the fixedImageReader-&gt;GetOutput()<BR>&gt; &gt; method, how could<BR>&gt; &gt; I ask
 the itk code to take the data directly from my image<BR>&gt; &gt; buffers - is this<BR>&gt; &gt; possible?<BR>&gt; &gt;<BR>&gt; &gt; registration-&gt;SetFixedImage( pBuff1 );<BR>&gt; &gt; registration-&gt;SetMovingImage( pBuff2 );<BR>&gt; &gt;<BR>&gt; &gt; Thank you for your time.<BR>&gt; &gt;<BR>&gt; &gt; _________________________________________________________________<BR>&gt; &gt; Choose now from 4 levels of MSN Hotmail Extra Storage - no<BR>&gt; &gt; more account<BR>&gt; &gt; overload! http://click.atdmt.com/AVE/go/onm00200362ave/direct/01/<BR>&gt; &gt;<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; Insight-users mailing list<BR>&gt; &gt; Insight-users at itk.org<BR>&gt; &gt; http://www.itk.org/mailman/listinfo/insight-&gt; users<BR>&gt; &gt;<BR>&gt;<BR>&gt;_______________________________________________<BR>&gt;Insight-users mailing
 list<BR>&gt;Insight-users at itk.org<BR>&gt;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--