<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2604" name=GENERATOR></HEAD>
<BODY>
<DIV>insight-users,您好!</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>MutualInformationImageToImageMetric&lt; TFixedImage,TMovingImage&gt; </DIV>
<DIV>::SampleFixedImageDomain(</DIV>
<DIV>&nbsp;&nbsp;SpatialSampleContainer&amp;&nbsp;samples&nbsp;)&nbsp;const</DIV>
<DIV>{</DIV>
<DIV>..............................</DIV>
<DIV>&nbsp;&nbsp;for(&nbsp;iter&nbsp;=&nbsp;samples.begin();&nbsp;iter&nbsp;!=&nbsp;end;&nbsp;++iter&nbsp;)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;get&nbsp;sampled&nbsp;index</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;FixedImageIndexType&nbsp;index&nbsp;=&nbsp;randIter.GetIndex();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;get&nbsp;sampled&nbsp;fixed&nbsp;image&nbsp;value</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;(*iter).FixedImageValue&nbsp;=&nbsp;randIter.Get();&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;get&nbsp;moving&nbsp;image&nbsp;value</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;m_FixedImage-&gt; 
TransformIndexToPhysicalPoint(&nbsp;index,&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*iter).FixedImagePointValue&nbsp;);&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT style="BACKGROUND-COLOR: #ffff00">&nbsp;&nbsp;&nbsp;&nbsp;//here, 
Transform should taking movImage to&nbsp;fixImage, why here uses just the 
opposite direction.</FONT></DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;MovingImagePointType&nbsp;mappedPoint&nbsp;=&nbsp;&nbsp;m_Transform-&gt; 
TransformPoint(&nbsp;(*iter).FixedImagePointValue&nbsp;);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;m_Interpolator-&gt; 
IsInsideBuffer(&nbsp;mappedPoint&nbsp;)&nbsp;)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*iter).MovingImageValue&nbsp;=&nbsp;m_Interpolator-&gt; 
Evaluate(&nbsp;mappedPoint&nbsp;);&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allOutside&nbsp;=&nbsp;false;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;else</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*iter).MovingImageValue&nbsp;=&nbsp;0;//出界点</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;jump&nbsp;to&nbsp;random&nbsp;position</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;++randIter;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</DIV>
<DIV>&nbsp;&nbsp;if(&nbsp;allOutside&nbsp;)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;if&nbsp;all&nbsp;the&nbsp;samples&nbsp;mapped&nbsp;to&nbsp;the&nbsp;outside&nbsp;throw&nbsp;an&nbsp;exception</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;itkExceptionMacro(&lt; &lt; 
"All&nbsp;the&nbsp;sampled&nbsp;point&nbsp;mapped&nbsp;to&nbsp;outside&nbsp;of&nbsp;the&nbsp;moving&nbsp;image"&nbsp;);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</DIV>
<DIV>&nbsp;}&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>        致</DIV>
<DIV>礼!</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>        庄吓海</DIV>
<DIV>        arhye@163.com</DIV>
<DIV>          2005-04-11</DIV></BODY></HTML>