Thanks Luis. Good to know about itkUnaryFunctorImageFilter.<br><br>The example I gave was specific but that was just a one time requirement. In general, I want to give a range, lets say 120-165, and change the values in this range to some x. According to my understanding the functions in ThresholdImageFilter (for example, ThresholdOutside()) and BinaryThresholdImageFilter classes changed the values outside the given range. Is that right or am I missing some way of changing the values inside the range?
<br><br>Is using itkUnaryFunctorImageFilter the best way to go about if I want to make a general ThresholdInside() function? If have that then I can very easily solve my original example plus more.<br><br>Thanks again.<br>
<br>-Sharath<br><br><div><span class="gmail_quote">On 10/12/07, <b class="gmail_sendername">Luis Ibanez</b> &lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi Sharath,<br><br>The Thresholding filter that you need is too specific and doesn&#39;t<br>match the profile of any of the filters we currently have.<br><br>However, it will be *very* easy for you to write one by taking
<br>advantage of the itkUnaryFunctorImageFilter.<br><br>You just need to write a Functor, and then instantiate the<br>itkUnaryFunctorImageFilter over the input image, output image<br>and the functor.<br><br><br>The functor that you need will look like:
<br>(asumming that your images are using &quot;unsigned char&quot; pixel type).<br><br><br>namespace Functor {<br><br>class MyThreshold<br>{<br>public:<br>&nbsp;&nbsp; MyThreshold() {};<br>&nbsp;&nbsp; ~MyThreshold() {};<br><br>&nbsp;&nbsp; bool operator!=( const BinaryThreshold &amp; other ) const
<br>&nbsp;&nbsp;&nbsp;&nbsp; { return false; }<br>&nbsp;&nbsp; bool operator==( const BinaryThreshold &amp; other ) const<br>&nbsp;&nbsp;&nbsp;&nbsp; { return !(*this != other); }<br><br>&nbsp;&nbsp; inline unsigned char operator()( const unsigned char &amp; A )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; if ( A ==&nbsp;&nbsp; 0 ) { return&nbsp;&nbsp; 0; }
<br>&nbsp;&nbsp;&nbsp;&nbsp; if ( A == 255 ) { return 255; }<br>&nbsp;&nbsp;&nbsp;&nbsp; if ( A &lt;&nbsp;&nbsp;127 ) { return 255; }<br>&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp; }<br>private:<br>};<br>}<br><br><br>Then you can instantiate:<br><br><br>typedef itk::UnaryFunctorImageFilter&lt;
<br>&nbsp;&nbsp; InputImageType, OutputImageType, Functor::MyThreshod &gt; FilterType;<br><br>FilterType::Pointer filter = FilterType::New();<br><br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;Regards,<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<br><br><br><br>-----------------------
<br>Sharath Cholleti wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I am new to ITK and started reading parts of the software guide as<br>&gt; required.<br>&gt;<br>&gt; I need to change the pixel values of an image to 255 if its value is
<br>&gt; between 1-127 and to 0 if its value is between 128-254. Keep all pixels<br>&gt; of 0 and 255&#39;s as they are. I noticed ThresholdOutside function in<br>&gt; ThresholdImageFilter but in a way I need a &quot;ThresholdInside&quot; function.&nbsp;&nbsp;Is
<br>&gt; there such a function that would allow me to do this?<br>&gt;<br>&gt; I looked at BinaryThresholdImageFilter and ThresholdImageFilter<br>&gt; classes for this particular problem.<br>&gt;<br>&gt; Thanks,<br>&gt;<br>
&gt; Sharath<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; <a href="mailto:Insight-users@itk.org">
Insight-users@itk.org</a><br>&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote></div><br>