<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hi, Luis:</DIV>
<DIV> </DIV>
<DIV>Thanks a lot. The problem is now solved.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Best regards</DIV>
<DIV> </DIV>
<DIV>Baoyun<BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Luis Ibanez <luis.ibanez@kitware.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li <baoyun_li123@yahoo.com><BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> insight-users@itk.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Fri, February 26, 2010 12:35:25 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [Insight-users] problem about template a class with itkimage<BR></FONT><BR>Hi Baoyun,<BR><BR><BR>Thanks for your detailed email.<BR><BR><BR>The error message indicates that in line 35 of the file<BR><BR> ChanVese.h<BR><BR>You are attempting to directly call the constructor of<BR>an itk::Image.<BR><BR>This is a common mistake and indicates that you<BR>have a line such as:<BR><BR>
ImageType myImage;<BR><BR>Instead of properly using Smart Pointers,<BR><BR><BR>The correct line should be something like:<BR><BR> typename ImageType::Pointer myImage;<BR><BR><BR>We declared "protected" the constructor and destructor<BR>methods of all the classes that are managed by<BR>SmartPointers, with the explicit intention of catching<BR>this common mistake. (and redirecting you to use the<BR>SmartPointers).<BR><BR><BR>You will find useful to read the "Data Representation"<BR>chapter of the ITK Software Guide:<BR><BR> http://www.itk.org/ItkSoftwareGuide.pdf<BR><BR>Where these issues are described in detail.<BR><BR><BR><BR> Regards,<BR><BR><BR><BR> Luis<BR><BR><BR><BR>-------------------------------------------------------<BR>On Fri, Feb 26, 2010 at 11:30 AM, Baoyun Li <<A href="mailto:baoyun_li123@yahoo.com"
ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A>> wrote:<BR>> Dear All:<BR>><BR>> I am trying to wirte some template class which is templated over<BR>> itkImage with following class defintion. At this time, I just want my code<BR>> to do somework with the help of itk tools. But something is wrong with my<BR>> constructor an deconstructoer although I did not do anything using them<BR>> now.<BR>><BR>> The error message shows me I should not call itkImage constructor or<BR>> destructor since they are protected. Can somebody tell me the right way to<BR>> do the work.<BR>><BR>> I have listed the code and error message.<BR>><BR>> Thanks and my best regards<BR>><BR>> Baoyun<BR>><BR>> 1. The intilization of this class<BR>><BR>> typedef ChanVese<InputImageType,InputImageType,float> ChanVeseType;<BR>>
ChanVeseType leveset1;<BR>><BR>> 2: class definition<BR>> ***************************************************<BR>><BR>><BR>> #ifndef _ChanVese_H<BR>> #define _ChanVese_H<BR>><BR>> #include "itkImage.h"<BR>> #include "itkImageFileReader.h"<BR>> #include "itkImageFileWriter.h"<BR>> #include "itkBinaryThresholdImageFilter.h"<BR>> using namespace std;<BR>> template <class TInputImage,class TFeatureImage,class TOutputPixelType><BR>> class ChanVese<BR>> {<BR>><BR>><BR>><BR>> public:<BR>> itkStaticConstMacro( ImageDimension, unsigned<BR>> int,TInputImage::ImageDimension );<BR>> typedef TFeatureImage FeatureImageType;<BR>> typedef typename FeatureImageType::PixelType FeaturePixelType;<BR>> typedef TInputImage InputImageType;<BR>>
typedef typename InputImageType::PixelType InputPixelType;<BR>> ChanVese()<BR>> {<BR>> std::cout<<"chan vesee desconstructed"<<std::endl;<BR>> }<BR>> ~ChanVese()<BR>> {<BR>> std::cout<<"chan vesee desconstructed"<<std::endl;<BR>> }<BR>><BR>> } ;<BR>> #endif<BR>><BR>> ******************************************************<BR>><BR>> --------------------------------------------------------------------------------------------------<BR>> /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.txx:34: error:<BR>> 'itk::Image<TPixel, VImageDimension>::Image() [with TPixel = short int,<BR>> unsigned int VImageDimension
= 3u]' is protected<BR>> /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:35:<BR>> error: within this context<BR>> /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/test.cxx:490:<BR>> instantiated from here<BR>> /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h:287: error:<BR>> 'itk::Image<TPixel, VImageDimension>::~Image() [with TPixel = short int,<BR>> unsigned int VImageDimension = 3u]' is protected<BR>> /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:35:<BR>> error: within this context<BR>> /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h: In destructor<BR>> 'ChanVese<TInputImage, TFeatureImage, TOutputPixelType>::~ChanVese() [with<BR>> TInputImage = itk::Image<short int, 3u>, TFeatureImage = itk::Image<short<BR>> int, 3u>, TOutputPixelType = float]':<BR>>
/home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/test.cxx:490:<BR>> instantiated from here<BR>> /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h:287: error:<BR>> 'itk::Image<TPixel, VImageDimension>::~Image() [with TPixel = short int,<BR>> unsigned int VImageDimension = 3u]' is protected<BR>> /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:42:<BR>> error: within this context<BR>> ------------------------------------------------------------------------------------------------------<BR>><BR>><BR>><BR>> _____________________________________<BR>> Powered by <A href="http://www.kitware.com/" target=_blank>www.kitware.com</A><BR>><BR>> Visit other Kitware open-source projects at<BR>> http://www.kitware.com/opensource/opensource.html<BR>><BR>> Kitware offers ITK Training Courses, for more information visit:<BR>>
http://www.kitware.com/products/protraining.html<BR>><BR>> Please keep messages on-topic and check the ITK FAQ at:<BR>> http://www.itk.org/Wiki/ITK_FAQ<BR>><BR>> Follow this link to subscribe/unsubscribe:<BR>> http://www.itk.org/mailman/listinfo/insight-users<BR>><BR>><BR></DIV></DIV></div><br>
</body></html>