[Insight-users] Histogram modification - troubles with SetFrequency

Luis Ibanez luis.ibanez at kitware.com
Sun Dec 6 21:10:14 EST 2009


Hi Sacrif,

Thanks for pointing this out.

This is indeed the case,  ITK filters own their output
and they are the only ones that should change the
output objects.

This is a requirement for good-behavior when the
filters are put into a pipeline.

You are not supposed to modify the output of a
filter.

In your case, you could create a new Histogram
manually, and copy the computed elements
from the output of the Histogram that you get from
the generator.

Something similar to:

const HistogramType * histogram1 = histogramGenerator->GetOutput();

HistogramType::Pointer histogram2 = HistogramType::New();

// Add here:
// Copy lower, upper values of bins
// Copy values of numbers of bins
// Allocate size for the new historgram2
//

//
//  Now copy the recomputed values
//
HistogramType::Iterator itr2 = historgram2->Begin();
HistogramType::ConstIterator itr1 = histogram1->Begin();

while( itr1 != histogram1->End() )
  {
  *itr2 = pow(  *itr1, 2.0 )
  ++itr1;
  ++itr2;
  }


  Regards,


        Luis


--------------------------------------------------------------------------------
On Fri, Dec 4, 2009 at 3:43 AM, sacrif <markus_m at gmx.net> wrote:
>
> Hi, I finally found out what the problem is. The histogram is defined as
> const HistogramType * histogram; or HistogramType::ConstPointer histogram;
>
> However the SetFrequency method is a not const method. Therefore non of the
> 4 SetFrequency methods is applicable on it.
>
> The problem is that the GetOutput() method of the
> itk::Statistics::ScalarImageToHistogramGenerator class returns a "const
> HistogramType *" which I assign to my "const HistogramType* histogram"
> pointer. So I can only define the histogram as const. But then the
> SetFrequency would not work. (and results in the compilation error: error
> C2663: 'itk::Statistics::Histogram<TMeasurement>::SetFrequency' : 4
> overloads have no legal conversion for 'this' pointer...<--as written in my
> previous post)
>
> Is it possible that a histogram as I defined it can't be changed as soon as
> it is created? Somehow I can't imagine this is the case. But at the moment I
> can only imagine to write the values in an std::vector to proceed working on
> it.
> I would appreciate any onther advice.
>
> Thank you & kind regards
>
> --
> View this message in context: http://old.nabble.com/Histogram-modification---troubles-with-SetFrequency-tp26615939p26635812.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
>
> _____________________________________
> 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://www.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-users
>


More information about the Insight-users mailing list