[Insight-users] image filter ThresholdInside?
Luis Ibanez
luis.ibanez at kitware.com
Fri Oct 12 16:23:09 EDT 2007
Hi Sharath,
The Thresholding filter that you need is too specific and doesn't
match the profile of any of the filters we currently have.
However, it will be *very* easy for you to write one by taking
advantage of the itkUnaryFunctorImageFilter.
You just need to write a Functor, and then instantiate the
itkUnaryFunctorImageFilter over the input image, output image
and the functor.
The functor that you need will look like:
(asumming that your images are using "unsigned char" pixel type).
namespace Functor {
class MyThreshold
{
public:
MyThreshold() {};
~MyThreshold() {};
bool operator!=( const BinaryThreshold & other ) const
{ return false; }
bool operator==( const BinaryThreshold & other ) const
{ return !(*this != other); }
inline unsigned char operator()( const unsigned char & A )
{
if ( A == 0 ) { return 0; }
if ( A == 255 ) { return 255; }
if ( A < 127 ) { return 255; }
return 0;
}
private:
};
}
Then you can instantiate:
typedef itk::UnaryFunctorImageFilter<
InputImageType, OutputImageType, Functor::MyThreshod > FilterType;
FilterType::Pointer filter = FilterType::New();
Regards,
Luis
-----------------------
Sharath Cholleti wrote:
> Hi,
>
> I am new to ITK and started reading parts of the software guide as
> required.
>
> I need to change the pixel values of an image to 255 if its value is
> between 1-127 and to 0 if its value is between 128-254. Keep all pixels
> of 0 and 255's as they are. I noticed ThresholdOutside function in
> ThresholdImageFilter but in a way I need a "ThresholdInside" function. Is
> there such a function that would allow me to do this?
>
> I looked at BinaryThresholdImageFilter and ThresholdImageFilter
> classes for this particular problem.
>
> Thanks,
>
> Sharath
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list