[Insight-users] Const label image as input to SetLabelInput(TLabelImage *input) in class LabelStatisticsImageFilter

Ricardo Ferrari rjf.araraquara at gmail.com
Wed Feb 3 14:06:45 EST 2010


Hi Guys,

I am trying to use the itk class LabelStatisticsImageFilter but I have the
following problem and doubt?

The label image I am getting from one of my own designed classes is const.
Now I would like to use it as an input to the

itk class LabelStatisticsImageFilter and I am getting the following error.

/home/ferrari/Workspace/MIP_PROJECTS/trunk/segmentation/gmm/TGMM_RelabelStrategy_MeanValue.txx:17:
error: invalid conversion from ‘const itk::Image<unsigned char, 3u>*’ to
‘itk::Image<unsigned char, 3u>*’


which I can easily understand.

Now, taking a look on the SetLabelInput function in the
itk class LabelStatisticsImageFilter I´ve notice that the input image is
converted to a const.


00228
00230   void SetLabelInput(TLabelImage *input)
00231     {
00232       // Process object is not const-correct so the const casting is
required.
00233       this->SetNthInput(1, const_cast<TLabelImage *>(input) );
00234     }


So, my question is, what is the reason for doing that. What´s the problem in
change the function to

void SetLabelInput( const TLabelImage *input) ????????


I really appreciate any help on this.

Thank you

Ricardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100203/657a26d7/attachment.htm>


More information about the Insight-users mailing list