No subject


Fri May 8 15:29:31 EDT 2009


nly defined in C++ for integer
types=2C the images passed to this filter must comply with the
requirement of using integer pixel type.


Geoff Topping

________________________________
> CC: luis.ibanez at kitware.com=3B insight-users at itk.org
> From: blowekamp at mail.nih.gov
> To: g_topping at hotmail.com
> Subject: Re: [Insight-users] NumericLimits::min float / int Inconsistency=
 Workaround?
> Date: Thu=2C 21 May 2009 09:24:39 -0400
>
> Geoff=2C
>
> What about using some boolean logic.
>
> !(NumericTraits<>::min() <=3D pixel <=3D NumericTraits<>::Zero) should be=
 equivalent to (NumericTraits<>::Zero < pixel)
>
> Just use a NotImageFilter? or perhaps write a read-only NotImageAdaptor i=
f you prefer.
>
> Brad
>
>
>
>
> On May 21=2C 2009=2C at 12:00 AM=2C Geoff Topping wrote:
>
>
> Hi again=2C
>
> It seems odd to write (and thus need to test and support) a separate spec=
ialized NonInclusiveLowerThresholdFilter when there already is a more gener=
al filter that could do the job given appropriate inputs.
>
> Is there a reason NumericTraits<>::PositiveMin can't / shouldn't be added=
? This would have applications outside the scope of my particular problem=
=2C and is a surprising omission=2C to me.
>
> If PositiveMin can't be added=2C I'd suggest modifying BinaryThresholdIma=
geFilter to take optional second parameters for the SetLowerThreshold and S=
etUpperThreshold functions. These parameters would be bools that indicate w=
hether the whether the threshold test should include values equal to the th=
reshold value. The default value would be inclusive thresholds=2C so as to =
not break existing code that expects the current behaviour.
>
> Alternatively=2C new functions named something like SetLowerThresholdIncl=
usive(bool) and SetUpperThresholdInclusive(bool) could set whether each thr=
eshold is inclusive=2C defaulting to the current behaviour=2C if default pa=
rameters are frowned upon.
>
> Similarly=2C SetUpperThresholdInclusive()=2C SetUpperThresholdExclusive) =
and equivalents for the lower threshold could work.
>
> I don't know if there is an established precedent elsewhere in ITK for ho=
w such situations should be handled...
>
> Geoff
>
> ----------------------------------------
> Date: Wed=2C 20 May 2009 23:41:40 -0400
> From: luis.ibanez at kitware.com
> To: g_topping at hotmail.com
> CC: insight-users at itk.org
> Subject: Re: [Insight-users] NumericLimits::min float / int Inconsistency=
 Workaround?
>
>
> Hi Geoff=2C
>
> Thanks for the clarifications.
>
> The simple option is to write your own thresholding filter.
>
> It is actually quite easy.
>
>
> Just do the following:
>
> A) Copy paste the files itkBinaryThresholdImageFilter. h and txx
>
> B) Rename them=2C and rename the class inside.
>
> C) Modify the .h file in lines 98-105.
>
> Replace:
>
> inline TOutput operator()( const TInput & A ) const
> {
> if ( m_LowerThreshold <=3D A && A <=3D m_UpperThreshold )
> {
> return m_InsideValue=3B
> }
> return m_OutsideValue=3B
> }
>
> with
>
> inline TOutput operator()( const TInput & A ) const
> {
> if ( m_LowerThreshold < A )
> {
> return m_InsideValue=3B
> }
> return m_OutsideValue=3B
> }
>
> D) Get rid of all references to Upper threshold
>
>
>
> and once you get it to work=2C
>
>
> We encourage you to share your new filter with the community
> by submitting it to the Insight Journal
>
> http://www.insight-journal.org
>
>
>
> Regards=2C
>
>
> Luis
>
>
>
> ---------------------
> Geoff Topping wrote:
> Hi Luis=2C
>
> If I use a lower threshold of NumericTraits::Zero=2C voxels with value eq=
ual to 0 are set to the inside value in the output image.
>
> Also=2C the comments in itkBinaryThresholdImageFilter.h say:
>
> * Values equal to either threshold is considered to be between the thresh=
olds.
>
> Geoff Topping
>
> ----------------------------------------
>
> Date: Wed=2C 20 May 2009 22:08:52 -0400
> From: luis.ibanez at kitware.com
> To: g_topping at hotmail.com
> CC: insight-users at itk.org
> Subject: Re: [Insight-users] NumericLimits::min float / int Inconsistency=
 Workaround?
>
>
> Hi Geoff=2C
>
> If what you want is to get all values larger than zero=2C
>
> what is wrong with using:
>
>
> UpperThreshold =3D NumericTraits::max()
> LowerThreshold =3D NumericTraits::Zero
>
> ??
>
>
> Something is contradictory in your description of
> requiremets.
>
>
>
> Luis
>
>
>
> -------------------------
> Geoff Topping wrote:
>
> Hi all=2C
>
> I'm trying to make an itk::BinaryThresholdImageFilter with a lower bound =
that includes all values larger than zero. Doing this in a generic way has =
proven difficult due to the inconsistency in how itk::NumericLimits reports=
 min values for float or integer types.
>
> To clarify=2C this code:
>
> std::cout << "NumericTraits float min: " << itk::NumericTraits::min() << =
std::endl=3B
> std::cout << "NumericTraits signed short min: " << itk::NumericTraits::mi=
n() << std::endl=3B
>
> outputs this:
>
> NumericTraits float min: 1.17549e-38
> NumericTraits signed short min: -32768
>
> And since I'm working with signed short pixels=2C I can't use NumericTrai=
ts::min() to set the lower threshold for my filter (although I presumably c=
ould if I was using float pixel type).
>
>
> This issue is not unique to itk::NumericTraits=2C but is present in std::=
numeric_limits as well=2C for reasons that are irrelivant to this discussio=
n.
>
>
> My question: Is there a reccommended ITK style workaround for this?
>
> I want to be able to set the lower-threshold for my filter in a generic w=
ay=2C so don't want to set it to constants 1 (integer)=2C as that would be =
well above the minimum positive value for a float type pixel.
>
> I can't use NumericTraits to get the positive minimum value representable=
 by the type=2C although NumericTraits seems to be the standard way of gett=
ing this sort of information in ITK code.
>
> I could use a separate thresholding step to get a mask image with Numeric=
Limits::Zero for values between NumericLimits::NonpositiveMin and NumericLi=
mits::Zero and NumericLimits::One outside that range=2C and then multiply m=
y original image by this mask to get a nonnegative image=2C and then apply =
a separate threshold filter on that=2C but I shouldn't need to do those ext=
ra steps.
>
>
> Notably=2C there exist implmentations of similar functions to resolve thi=
s=2C including one in the Boost libraries:
>
> http://www.boost.org/doc/libs/1_38_0/libs/numeric/conversion/doc/html/boo=
st_numericconversion/bounds___traits_class.html
>
> I'm not using any Boost code in my current programs=2C though.
>
>
> Is there a reason NumericTraits doesn't have a function to provide the va=
lue I need?
>
> NumericTraits does have a NonpositiveMin() function=2C for a similar purp=
ose=2C which is implemented differently for float and integer types:
>
> static float NonpositiveMin() { return -vcl_numeric_limits::max()=3B }
>
> static int NonpositiveMin() { return vcl_numeric_limits::min()=3B }
>
>
> Thanks=2C
> Geoff Topping
>
>
> _________________________________________________________________
> Create a cool=2C new character for your Windows Live=99 Messenger.
> http://go.microsoft.com/?linkid=3D9656621
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.or=
g/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
> _________________________________________________________________
> One at a time or all at once? Get updates from your friends in one place.
> http://go.microsoft.com/?linkid=3D9660827
>
> _________________________________________________________________
> Windows Live helps you keep up with all your friends=2C in one place.
> http://go.microsoft.com/?linkid=3D9660826
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.or=
g/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
>
> Bradley Lowekamp
>
> Lockheed Martin Contractor for
>
> Office of High Performance Computing and Communications
>
> National Library of Medicine
>
> blowekamp at mail.nih.gov
>
>

_________________________________________________________________
One at a time or all at once? Get updates from your friends in one place.
http://go.microsoft.com/?linkid=3D9660827=


More information about the Insight-users mailing list