[Insight-developers] Question regarding itkColorTable
Luis Ibanez
luis.ibanez at kitware.com
Thu Jan 14 18:40:13 EST 2010
James,
Sounds good.
Just note that, because this class is in the Code/Common directory,
we have to make sure that the modifications are backward-compatible.
That is, the class, when used with the default values should behave
just as it did in ITK 3.16.
It will be a good idea to log a bug entry in MANTIS before you modify
the code. In this way there will be a better trace of the motivation and
rationale for the change.
Thanks
Luis
-----------------------------------------------------
On Thu, Jan 14, 2010 at 2:05 PM, James Ross <jross at bwh.harvard.edu> wrote:
> Hi Luis,
>
> Thanks for your reply. My personal preference would be for option 1 (the
> more flexible of the two). I can plan on making the change and committing if
> there are no objections.
>
> Regards,
>
> -James
>
> Luis Ibanez wrote:
>>
>> Hi James,
>>
>> Thanks for pointing this out.
>>
>> You are right this looks like a bug.
>>
>>
>> It was probably thought for the case of "unsigned char"
>> types, where "max()" will make sense.
>>
>>
>> The following couple of options
>> come to mind for fixing this issue:
>>
>> 1) Have member variables
>> * m_ComponentMinimum
>> * m_ComponentMaximum
>>
>> that will be initialized by default in the constructor
>> to the values
>>
>> NumericTraits<TPixel>::NonpositiveMin(),
>> NumericTraits<TPixel>::max())
>>
>> respectively,
>>
>> and that could also be set by the user via
>> SetMacro() methods.
>>
>>
>> OR
>>
>>
>> 2) Provide specialized ColorTraits<> classes
>> that will define the proper Min and Max values
>> for every type.
>>
>>
>>
>> The advantage of the first method is that it is
>> more flexible.
>>
>> The advantage of the second method is that
>> it will choose the "best" values by default.
>>
>>
>> What do you think of these two options ?
>>
>>
>>
>> Thanks
>>
>>
>>
>> Luis
>>
>>
>>
>> -----------------------------------------------------------
>> On Wed, Dec 23, 2009 at 11:00 AM, James Ross <jross at bwh.harvard.edu>
>> wrote:
>>
>>>
>>> Greetings,
>>>
>>> I have recently been working with itkColorTable and have a question about
>>> the UseRandomColors method. When I attempt the following:
>>>
>>> typedef itk::ColorTable< float > ColorType;
>>>
>>> ColorType::Pointer colorTable = ColorType::New();
>>> colorTable->UseRandomColors( 5000 );
>>>
>>> my program crashes.
>>>
>>> However, if I alter the body of ::UseRandomColors from:
>>>
>>> r = static_cast<TPixel>(vnl_sample_uniform(NumericTraits<TPixel>
>>> ::NonpositiveMin(),
>>> NumericTraits<TPixel>::max()));
>>> m_Color[i].SetRed( r );
>>> g = static_cast<TPixel>(vnl_sample_uniform(NumericTraits<TPixel>
>>> ::NonpositiveMin(),
>>> NumericTraits<TPixel>::max()));
>>> m_Color[i].SetGreen( g );
>>> b = static_cast<TPixel>(vnl_sample_uniform(NumericTraits<TPixel>
>>> ::NonpositiveMin(),
>>> NumericTraits<TPixel>::max()));
>>> m_Color[i].SetBlue( b );
>>>
>>> to:
>>>
>>> r = static_cast<TPixel>( vnl_sample_uniform( 0.0, 1.0 ) );
>>> m_Color[i].SetRed( r );
>>> g = static_cast<TPixel>( vnl_sample_uniform( 0.0, 1.0 ) );
>>> m_Color[i].SetGreen( g );
>>> b = static_cast<TPixel>( vnl_sample_uniform( 0.0, 1.0 ) );
>>> m_Color[i].SetBlue( b );
>>>
>>> my program runs, and I get expected behavior. Why are the color
>>> components
>>> randomly chosen in the interval from non-positive min to max in the
>>> original? Isn't the floating point color component convention associated
>>> with the interval [0.0, 1.0]? If the original is a logical bug, I'd be
>>> happy to fix and commit. If I'm doing something incorrectly, please let
>>> me
>>> know.
>>>
>>> Many thanks,
>>>
>>> -James
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>>
>
>
More information about the Insight-developers
mailing list