<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE></TITLE>
<META content="MSHTML 6.00.2900.2604" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=317191813-18052005><FONT face=Arial color=#0000ff size=2>Can
you use:</FONT></SPAN></DIV>
<DIV><SPAN class=317191813-18052005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=317191813-18052005><EM>it.Set(
static_vast<OutputPixelType>(sum * ( 1.0 / double(neighbothoodSize)))
); </EM></SPAN></DIV>
<DIV><SPAN class=317191813-18052005><EM></EM></SPAN> </DIV>
<DIV><SPAN class=317191813-18052005><EM>A better option is probably to add
scalar division (by a floating point type) to the RGBPixel
type.</EM></SPAN></DIV>
<DIV><SPAN class=317191813-18052005><EM></EM></SPAN> </DIV>
<DIV><SPAN class=317191813-18052005><EM>Jim</EM></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
insight-users-bounces+millerjv=crd.ge.com@itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of
</B>Bradley Lowekamp<BR><B>Sent:</B> Tuesday, May 17, 2005 4:58
PM<BR><B>To:</B> insight-users@itk.org<BR><B>Subject:</B> [Insight-users] Bug
with fix Mean Image Filter<BR><BR></FONT></DIV>
<P>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 </P><BR><BR>
<P><I>// get the mean value </I></P>
<P><I>it.Set( static_vast<OutputPixelType>(sum /
double(neighbothoodSize)) ); </I></P><BR><BR>
<P>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: </P><BR>
<P>// get the mean value<I> </I></P>
<P><I>it.Set( static_vast<OutputPixelType>(sum *
(1.0/NumericTraits<OutputPixelType>::ScalarRealType(neighbothoodSize)))
); </I></P><BR><BR>
<P>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. </P><BR>
<P>Thanks. </P><BR><BR><BR>
<P>======================================================== </P>
<P>Bradley Lowekamp </P>
<P>Management Systems Designers Contractor for </P>
<P>Office of High Performance Computing and Communications </P>
<P>National Library of Medicine </P>
<P>'blowekamp@mail.nih.gov</P></BLOCKQUOTE></BODY></HTML>