[Insight-users] Bug with fix Mean Image Filter

Luis Ibanez luis.ibanez at kitware.com
Wed May 18 22:11:29 EDT 2005


Hi Brad,


As we explained in a companion email:

    http://www.itk.org/pipermail/insight-users/2005-May/013165.html


RGBPixels are not expected to perform arithmetic opearations.

This is due to the fact that Color Spaces are not Vector Spaces.

The reason is unrelated to the actual precision type used for
representing each color componente. That is, the problem is not
that the RGBPixel has been designed for unsigned chars.

The problem is that there operation of "division by a scalar"
is not defined in a color RGB space.   You can, of course, force
it and provide your own interpretation of what it may mean to
divide a color by a scalar.

If you find that approach convenient, you may simply use the
itk::Vector<float,3> type for representing the three channels
as independent channels.

Note that the RGB space *is not* composed of independent signals
because the spectral response of the three color sensors in the
human eye have an overlaping spectral support. You could think
of this as, the RGB space not forming an orthogonal basis (although,
again.... a color space is not a vector space).


At this point you should probably decide if you care about the
physical reality behing the RGB colors in your image, or you just
want to use them as three independent channels of information.

If you are doing something like detectin skin cancer using
video images... you should rather look carefully at the concepts
of colorimetry and photometry that would be fundamental for such
a problem.

A good introductory site is the Color entry in the wikipedia:


     http://en.wikipedia.org/wiki/Color

where you will find a sketch of the spectral response of human
cones


    http://en.wikipedia.org/wiki/Image:Cone-response.png


Note for example that the combination of all RGB values cannot
represent all combinations of colors that are physically possible.


The diagram:

http://en.wikipedia.org/wiki/Image:Cie_chromaticity_diagram_wavelength.png

will help you understand why is that linear operation in the numeric
space of RGB do not correspond to the notion of color interpolation
as far as human perception goes.




So, the problem that you are confronting, is not a bug in the
MeanImage filter, nor a bug in the RGBPixel, but a questionable
interpretation of what RGB values mean in an image.




     Regards,



         Luis





======================

Bradley Lowekamp wrote:

> I was trying to use mean Image Filter with RGBPixel Type. This failed 
> because this pixel type did not supported the needed operator. This was 
> the line
> /
> // get the mean value
> it.Set( static_vast<OutputPixelType>(sum / double(neighbothoodSize)) );
> 
> 
> /RGBPixels do not support the divide by scalars operator. Perhaps 
> because this type may have only been designed to used with unsigned 
> chars? Any way the fix I coded up was:
> 
> // get the mean value/
> it.Set( static_vast<OutputPixelType>(sum * 
> (1.0/NumericTraits<OutputPixelType>::ScalarRealType(neighbothoodSize))) );
> /
> 
> However, that didn't work because NumericTraits<RGBPixel<unsigned char>> 
> does not have a ScalarRealType member, like every other numeric traits. 
> I actually am using RGBPixelType<double> but I implemented the numeric 
> traits my self.
> 
> Thanks.
> /
> 
> /========================================================
> Bradley Lowekamp
> Management Systems Designers Contractor for
> Office of High Performance Computing and Communications
> National Library of Medicine
> 'blowekamp at mail.nih.gov
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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