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

Luis Ibanez luis.ibanez at kitware.com
Fri Feb 5 13:24:00 EST 2010


Hi Ricardo,

Thanks for pointing this out.

This is an implementation mistake.

The methods

         SetInputLabel and
         GetInputLabel()

should have const interfaces.

Here is the Fix:

$ cvs diff itkLabelStatisticsImageFilter.h
Index: itkLabelStatisticsImageFilter.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/BasicFilters/itkLabelStatisticsImageFilter.h,v
retrieving revision 1.13
diff -r1.13 itkLabelStatisticsImageFilter.h
241c241
<   void SetLabelInput(TLabelImage *input)
---
>   void SetLabelInput(const TLabelImage *input)
248c248
<   LabelImageType * GetLabelInput()
---
>   const LabelImageType * GetLabelInput() const


We just committed a fix to the CVS repository.


     Thanks


           Luis


-------------------------------------------------------
On Wed, Feb 3, 2010 at 2:06 PM, Ricardo Ferrari
<rjf.araraquara at gmail.com> wrote:
> 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
>
>
> _____________________________________
> 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