View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010157ITKpublic2010-01-18 13:502010-11-02 12:11
ReporterJames Ross 
Assigned ToBill Lorensen 
PrioritynormalSeverityminorReproducibilitysometimes
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0010157: itkColorTable produces invalid color channel values
DescriptionitkColorTableTest investigates two types: unsigned char and short. The test performs a print on these types and returns true upon completion. However, no checking is performed to insure color components are within expected ranges (e.g. with non-negative color channels).

With ‘UseHeatColors’ templated over ‘unsigned char’ or ‘short’, half the colors are mapped to [0, 0, 0] and half are mapped to [1, 0, 0]. Perhaps it is better to perform the mapping such that color ID 0 maps to [0, 0, 0] and color ID max maps to [255, 0, 0] in a “continuous” way.

Specifying ‘short’ data type results in negative entries when using random colors and gray colors. Negative color channel values should be forbidden. Channel values should be in the interval [0, 1] or [0, 255] in general.

Specifying ‘float’ data type crashes:

typedef itk::ColorTable< float > FloatTableType;
FloatTableType::Pointer colors = FloatTableType::New();
  colors->UseRandomColors( 16 );
  colors->Print( std::cout ); // Crash
TagsNo tags attached.
Resolution Date
Sprint
Sprint Statusbacklog
Attached Files

 Relationships

  Notes
(0022777)
Hans Johnson (developer)
2010-11-02 11:29

Bill,


I think you actually addressed this recently. Will you close this bug if your recent work addresses this?

Hans
(0022782)
Bill Lorensen (developer)
2010-11-02 12:07

This was fixed recently.
http://itk.org/gitweb?p=ITK.git;a=commit;h=9323eeb1da1891fa6f86f935256598fe2444e7ec [^]

Here is the commit message:
BUG: UseGrayColors arithmetic exceptions.

The UseGrayColors range and delta computations were overflowing for
several PixelTypes. The signed integral types overflowed because the
range calculation and the i * delta overflowed.

The test was enhanced to exercise all types as well as the

GetClosestColorTableId() and GetColorName() methods.

API: Changed range of generated color table values.
The range for continuous types is now between 0 and 1 while the range
for integral types is NonpositiveMin() to max(). This makes the color
table range consistent for all table generators.

API: Converted m_Color and m_ColorName to use strings rather than char *.
GetColorName now returns an std::string rather than a char *.

BUG: UseGrayColors(1) caused a zero divide.
Now tests for 1 color. Enhanced test to include UseColors(1).

Change-Id: I46d74919c454446c275c6cda0f5261ee0413a93e

Here is the gerrit discussion:
http://review.source.kitware.com/#change,216 [^]
(0022783)
Bill Lorensen (developer)
2010-11-02 12:10

To use this fixed class in previous releases, download:
itkColorTable.h
http://itk.org/gitweb?p=ITK.git;a=blob;f=Code/Common/itkColorTable.h;h=7a065858038c7b454bf9a09efb4cd68f7db37a9f;hb=9323eeb1da1891fa6f86f935256598fe2444e7ec [^]

and
itkColorTable.txx
http://itk.org/gitweb?p=ITK.git;a=blob;f=Code/Common/itkColorTable.txx;h=12f421fcfcad45faf1c2cb751ca890806ceec4c3;hb=9323eeb1da1891fa6f86f935256598fe2444e7ec [^]

 Issue History
Date Modified Username Field Change
2010-01-18 13:50 James Ross New Issue
2010-11-02 11:28 Hans Johnson Status new => assigned
2010-11-02 11:28 Hans Johnson Assigned To => Bill Lorensen
2010-11-02 11:29 Hans Johnson Note Added: 0022777
2010-11-02 12:07 Bill Lorensen Sprint Status => backlog
2010-11-02 12:07 Bill Lorensen Note Added: 0022782
2010-11-02 12:07 Bill Lorensen Resolution open => fixed
2010-11-02 12:10 Bill Lorensen Note Added: 0022783
2010-11-02 12:11 Bill Lorensen Status assigned => closed


Copyright © 2000 - 2018 MantisBT Team