[ITK] (no subject)

Zein Salah zeinsalah at gmail.com
Mon Oct 27 10:48:49 EDT 2014


well,

thanks first for the feedback. I now wrote this code:

 typedef itk::Statistics::ScalarImageToHistogramGenerator< InputImageType
>   ScalarImageToHistogramGeneratorType;
 typedef ScalarImageToHistogramGeneratorType::HistogramType
HistogramType;

 ScalarImageToHistogramGeneratorType::Pointer
scalarImageToHistogramGenerator =
ScalarImageToHistogramGeneratorType::New();
 scalarImageToHistogramGenerator->SetNumberOfBins(128);
 scalarImageToHistogramGenerator->SetInput( m_ShiftedImage );
 scalarImageToHistogramGenerator->Compute();

HistogramType::Pointer hist =
scalarImageToHistogramGenerator->GetOutput();  // This statement causes the
error

SaveHistogram(hist, "c:/Hist.txt");

Now: the compiler gives an error

 error C2440: 'Initialisierung': 'const
itk::Statistics::Histogram<TMeasurement,VMeasurementVectorSize,TFrequencyContainer>
*' kann nicht in 'itk::SmartPointer<TObjectType>' konvertiert werden
1>        with
1>        [
1>            TMeasurement=double,
1>            VMeasurementVectorSize=1,
1>            TFrequencyContainer=itk::Statistics::DenseFrequencyContainer
1>        ]
1>        and
1>        [
1>
TObjectType=itk::Statistics::Histogram<double,1,itk::Statistics::DenseFrequencyContainer>
1>        ]


Translation:

'const
itk::Statistics::Histogram<TMeasurement,VMeasurementVectorSize,TFrequencyContainer>
*'

cannot be converted to

'itk::SmartPointer<TObjectType>'



On Mon, Oct 27, 2014 at 2:11 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>
wrote:

> Hello,
>
> The Histogram class is derived from the itk::Object class. Just about all
> ITK Object must manage by smart pointers, and must be dynamically created.
> The typical usage of an object type is:
>
> HistogramType::Pointer histogramPointer = HistogramType::New();
>
> This dynamically creates an Histogram, and uses the correct smart pointer
> type.
>
>
> This particular error message:
>
> On Oct 27, 2014, at 8:17 AM, Zein Salah <zeinsalah at gmail.com> wrote:
> >
> > error
> C2248::itk::Statistics::Histogram<TMeasurement,VMeasurementVectorSize,TFrequencyContainer>::~Histogram":
>
>
> is an indication that you are passing the type by value an not by a
> pointer. You should pass the histogram as PointerType of the class or as a
> raw pointer if there is not an issue of ownership that the smart pointe
> need to preserve.
>
> Brad
>
> p.s. You didn't include any of you code that was causing the problem. This
> is quite a luck case where I new the cause of the error message with out
> even seeing the code. It's best practice to include some code so that other
> can see what's causing the problem.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20141027/57aa1370/attachment.html>


More information about the Community mailing list