<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
To improve myself:<br>
<br>
the NumericTraits&lt;TOutput&gt;::min() should also be
NumericTraits&lt;TOutput&gt;::NonPositiveMin(), I guess.<br>
<br>
Also the documentation seems incorrect. At line 39 it reads:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; * - compute the constrained value (constrained to be greater than
or equal to the minimum value of the<br>
&nbsp; &nbsp;&nbsp; *&nbsp;&nbsp; input 1 pixel type<br>
But the implementation is that it should be greater than the minimum
value of the <b>*output*</b> type.<br>
<br>
Similar possible errors are made in the
ConstrainedValueAdditionImageFilter.<br>
<br>
Regards,<br>
<br>
Marius<br>
<br>
Marius Staring wrote:
<blockquote cite="mid45DC68CD.8040707@isi.uu.nl" type="cite">Hi,
  <br>
  <br>
The implementation of the operator() in the functor of the
ConstrainedValueDifferenceImageFilter now reads:
  <br>
  <br>
&nbsp;&nbsp; const double dA = static_cast&lt;double&gt;( A );
  <br>
&nbsp;&nbsp; const double dB = static_cast&lt;double&gt;( B );
  <br>
&nbsp;&nbsp; const double diff = dA - dB;
  <br>
&nbsp;&nbsp; const double cdiff = ( diff &gt; NumericTraits&lt;TOutput&gt;::min()
) ? diff : NumericTraits&lt;TOutput&gt;::min();
  <br>
&nbsp;&nbsp; return static_cast&lt;TOutput&gt;( cdiff );
  <br>
  <br>
I think that should be
  <br>
  <br>
&nbsp;&nbsp; const double dA = static_cast&lt;double&gt;( A );
  <br>
&nbsp;&nbsp; const double dB = static_cast&lt;double&gt;( B );
  <br>
&nbsp;&nbsp; const double diff = dA - dB;
  <br>
&nbsp;&nbsp; const double cdiff1 = ( diff &gt;
NumericTraits&lt;TOutput&gt;::min() ) ? diff :
NumericTraits&lt;TOutput&gt;::min();
  <br>
&nbsp;&nbsp; const double cdiff2 = ( cdiff1 &lt;
NumericTraits&lt;TOutput&gt;::max() ) ? diffc1 :
NumericTraits&lt;TOutput&gt;::max();
  <br>
&nbsp;&nbsp; return static_cast&lt;TOutput&gt;( cdiff2 );
  <br>
  <br>
or am I missing something?
  <br>
  <br>
Cheers,
  <br>
  <br>
</blockquote>
<br>
<pre class="moz-signature" cols="60">-- 
Marius Staring
Image Sciences Institute
University Medical Centre Utrecht
Heidelberglaan 100, 3584 CX Utrecht, The Netherlands
phone: +31 (0)30 250 3186, fax: +31 (0)30 251 3399
<a class="moz-txt-link-abbreviated" href="mailto:marius@isi.uu.nl">marius@isi.uu.nl</a>, <a class="moz-txt-link-freetext" href="http://www.isi.uu.nl/People/Marius">http://www.isi.uu.nl/People/Marius</a></pre>
</body>
</html>