[Insight-users] Histogram creation...

Jean-Philippe Guyon jguyon at ils-inc.com
Fri, 16 Jan 2004 10:34:15 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_0011_01C3DC1C.4A001420
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello,

I am trying to create a histogram that contains values of all the pixels
within a volume extracted using the GeodesicActiveContour approach provided
by ITK.
Basically, the result of the segmentation algorithm is used as a mask for
the histogram generation.
I am using the code below and I get the following exception when I call the
final Update():

itk::ERROR: Histogram(0581A178): One of the measurement components is below
the minimum

I find it surprising to get that error message since the image processed
contains only positive values.
Any idea why this happens ???

Jean-Philippe

----------------------------------------------------------------------------
-----------------------------------

typedef typename itk::Vector<typename InputType::PixelType,1>
VectorType;
typedef typename itk::Statistics::ListSample<VectorType >
HistogramSampleType;
typedef typename HistogramSampleType::Pointer
HistogramSamplePointer;
typedef typename itk::Statistics::Histogram<typename MaskType::PixelType,1 >
HistogramType;
typedef typename HistogramType::Pointer
HistogramPointer;
typedef typename HistogramType::SizeType
HistogramSizeType;
typedef itk::Statistics::ListSampleToHistogramFilter< HistogramSampleType,
HistogramType > HistogramFilterType;
typedef typename HistogramFilterType::Pointer
HistogramFilterPointer;

//....
// Definition of iterators, etc....
//....

HistogramType::SizeType size;
HistogramType::MeasurementVectorType min;
HistogramType::MeasurementVectorType max;

size.Fill(25);
min.Fill(0);
max.Fill(999999);

this->m_Histogram = HistogramType::New();
this->m_Histogram->Initialize(size,min,max);

this->m_HistogramSample = HistogramSampleType::New();

this->m_HistogramGenerator = HistogramFilterType::New();
this->m_HistogramGenerator->SetListSample(this->m_HistogramSample);
this->m_HistogramGenerator->SetHistogram(this->m_Histogram);

while(!maskIt.IsAtEnd())
{
    if(maskIt.Value())
    {
    this->m_HistogramSample->PushBack(inputIt.Value());
    }
    ++maskIt;
    ++inputIt;
}

this->m_HistogramGenerator->Update();


------=_NextPart_000_0011_01C3DC1C.4A001420
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR></HEAD>
<BODY>
<DIV>
<P><SPAN class=3D162200615-16012004></SPAN><FONT color=3D#0000ff><FONT=20
size=3D2>H</FONT><SPAN class=3D162200615-16012004><FONT=20
size=3D2>ello,<BR></FONT></SPAN></FONT><FONT><BR><SPAN=20
class=3D162200615-16012004></SPAN><FONT color=3D#0000ff><FONT =
size=3D2><FONT=20
face=3DArial>I<SPAN class=3D162200615-16012004> am trying to create a =
histogram that=20
contains&nbsp;values of all the pixels&nbsp;within a volume extracted =
using the=20
GeodesicActiveContour approach provided by ITK.<BR>Basically, the result =
of the=20
segmentation algorithm is used as a mask for the histogram=20
generation.<BR></SPAN></FONT></FONT></FONT></FONT><FONT><FONT><FONT=20
color=3D#0000ff><FONT size=3D2><FONT face=3DArial><SPAN =
class=3D162200615-16012004>I am=20
using the&nbsp;code below&nbsp;and I get&nbsp;the =
following&nbsp;exception when=20
I call the final Update():</SPAN></FONT><BR><BR><SPAN=20
class=3D162200615-16012004></SPAN><FONT =
face=3DArial>i</FONT></FONT></FONT><FONT=20
color=3D#0000ff><FONT size=3D2><FONT face=3DArial><SPAN=20
class=3D162200615-16012004>tk::ERROR: Histogram(0581A178): One of the =
measurement=20
components is below the minimum<BR><BR><SPAN =
class=3D162200615-16012004>I find it=20
surprising to get that error message since the image&nbsp;processed=20
contains&nbsp;only positive values.<BR></SPAN>Any idea why this happens =
???=20
</SPAN></FONT></FONT></FONT></FONT></FONT><FONT><FONT><FONT =
color=3D#0000ff><FONT=20
size=3D2><FONT face=3DArial><SPAN=20
class=3D162200615-16012004><BR><BR>Jean-Philippe<BR><BR></SPAN><SPAN=20
class=3D162200615-16012004></SPAN>-<SPAN=20
class=3D162200615-16012004>----------------------------------------------=
----------------------------------------------------------------<BR></SPA=
N></FONT><BR>typedef</FONT></FONT></FONT></FONT><FONT=20
size=3D2> <FONT color=3D#0000ff>typename</FONT> itk::Vector&lt;<FONT=20
color=3D#0000ff>typename</FONT> InputType::PixelType,1&gt;&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN>VectorType;<BR><FONT color=3D#0000ff>typedef</FONT> <FONT=20
color=3D#0000ff>typename</FONT> =
itk::Statistics::ListSample&lt;VectorType=20
&gt;&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN>HistogramSampleType;<BR><FONT color=3D#0000ff>typedef</FONT> =
<FONT=20
color=3D#0000ff>typename</FONT> HistogramSampleType::Pointer&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN>HistogramSamplePointer;<BR><FONT color=3D#0000ff>typedef</FONT> =
<FONT=20
color=3D#0000ff>typename</FONT> itk::Statistics::Histogram&lt;<FONT=20
color=3D#0000ff>typename</FONT> MaskType::PixelType,1 &gt;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp; =
</SPAN>HistogramType;<BR><FONT=20
color=3D#0000ff>typedef</FONT> <FONT color=3D#0000ff>typename</FONT>=20
HistogramType::Pointer&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
</SPAN>HistogramPointer;<BR><FONT color=3D#0000ff>typedef</FONT> <FONT=20
color=3D#0000ff>typename</FONT> HistogramType::SizeType&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>Histogra=
mSizeType;<BR><FONT=20
color=3D#0000ff>typedef</FONT> =
itk::Statistics::ListSampleToHistogramFilter&lt;=20
HistogramSampleType, HistogramType &gt; HistogramFilterType;<BR><FONT=20
color=3D#0000ff>typedef</FONT> <FONT color=3D#0000ff>typename</FONT>=20
HistogramFilterType::Pointer&nbsp;<SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
</SPAN>HistogramFilterPointer;</FONT></P></DIV>
<DIV>
<P><SPAN class=3D162200615-16012004></SPAN><FONT size=3D2>/<SPAN=20
class=3D162200615-16012004>/....<BR>// Definition of iterators,=20
etc....<BR>//....</SPAN></FONT><FONT =
size=3D2><BR><BR>HistogramType::SizeType=20
size;<BR>HistogramType::MeasurementVectorType=20
min;<BR>HistogramType::MeasurementVectorType max;<BR><BR>size.Fill(25);=20
<BR>min.Fill(0);</FONT><FONT color=3D#008000><BR></FONT><FONT=20
size=3D2>max.Fill(999999);</FONT><FONT =
color=3D#008000><BR><BR></FONT><FONT=20
size=3D2><FONT color=3D#0000ff>this</FONT>-&gt;m_Histogram =3D=20
HistogramType::New();<BR><FONT=20
color=3D#0000ff>this</FONT>-&gt;m_Histogram-&gt;Initialize(size,min,max);=
<BR><BR><FONT=20
color=3D#0000ff>this</FONT>-&gt;m_HistogramSample =3D=20
HistogramSampleType::New();<BR><BR><FONT=20
color=3D#0000ff>this</FONT>-&gt;m_HistogramGenerator =3D=20
HistogramFilterType::New();<BR><FONT=20
color=3D#0000ff>this</FONT>-&gt;m_HistogramGenerator-&gt;SetListSample(<F=
ONT=20
color=3D#0000ff>this</FONT>-&gt;m_HistogramSample);<BR><FONT=20
color=3D#0000ff>this</FONT>-&gt;m_HistogramGenerator-&gt;SetHistogram(<FO=
NT=20
color=3D#0000ff>this</FONT>-&gt;m_Histogram);</FONT><FONT=20
size=3D2><BR><BR>while(!maskIt.IsAtEnd())<BR>{<BR><SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp; =
</SPAN>if(maskIt.Value())<BR><SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp; </SPAN>{<BR><FONT=20
color=3D#0000ff><SPAN class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;=20
</SPAN>this</FONT>-&gt;m_HistogramSample-&gt;PushBack(<SPAN=20
class=3D162200615-16012004>inputIt.Value()</SPAN>);<BR><SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp; </SPAN>}<BR><SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp; </SPAN>++maskIt;<BR><SPAN=20
class=3D162200615-16012004>&nbsp;&nbsp;&nbsp;=20
</SPAN>++inputIt;<BR>}<BR></FONT><FONT size=3D2><FONT color=3D#0000ff=20
size=3D2><BR>this</FONT><FONT=20
size=3D2>-&gt;m_HistogramGenerator-&gt;Update();</FONT></FONT></P></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0011_01C3DC1C.4A001420--