<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>&nbsp;</DIV>
<DIV>Thanks a lot. The problem is now solved.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Best regards</DIV>
<DIV>&nbsp;</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 &lt;luis.ibanez@kitware.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li &lt;baoyun_li123@yahoo.com&gt;<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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChanVese.h<BR><BR>You are attempting to directly call the constructor of<BR>an&nbsp; itk::Image.<BR><BR>This is a common mistake and indicates that you<BR>have a line such as:<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 ImageType&nbsp; &nbsp; &nbsp; myImage;<BR><BR>Instead of properly using Smart Pointers,<BR><BR><BR>The correct line should be something like:<BR><BR>&nbsp; &nbsp; &nbsp; typename ImageType::Pointer&nbsp; &nbsp; 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>&nbsp; &nbsp; &nbsp; &nbsp; http://www.itk.org/ItkSoftwareGuide.pdf<BR><BR>Where these issues are described in detail.<BR><BR><BR><BR>&nbsp; Regards,<BR><BR><BR><BR>&nbsp; &nbsp; &nbsp; Luis<BR><BR><BR><BR>-------------------------------------------------------<BR>On Fri, Feb 26, 2010 at 11:30 AM, Baoyun Li &lt;<A href="mailto:baoyun_li123@yahoo.com"
 ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A>&gt; wrote:<BR>&gt; Dear All:<BR>&gt;<BR>&gt; I am trying to wirte some template class which is templated over<BR>&gt; itkImage&nbsp;with&nbsp;&nbsp;following class defintion. At this time, I just want my code<BR>&gt; to do somework with the help of itk tools. But something is wrong with my<BR>&gt; constructor an deconstructoer although&nbsp; I did not do anything using them<BR>&gt; now.<BR>&gt;<BR>&gt; The error message shows me I should not call itkImage constructor or<BR>&gt; destructor since they are protected.&nbsp; Can somebody tell me the right way to<BR>&gt; do the work.<BR>&gt;<BR>&gt; I have listed the code and error message.<BR>&gt;<BR>&gt; Thanks and my best regards<BR>&gt;<BR>&gt; Baoyun<BR>&gt;<BR>&gt; 1.&nbsp;&nbsp; The intilization of this class<BR>&gt;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp; typedef ChanVese&lt;InputImageType,InputImageType,float&gt; ChanVeseType;<BR>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ChanVeseType leveset1;<BR>&gt;<BR>&gt; 2: class definition<BR>&gt; ***************************************************<BR>&gt;<BR>&gt;<BR>&gt; #ifndef _ChanVese_H<BR>&gt; #define _ChanVese_H<BR>&gt;<BR>&gt; #include "itkImage.h"<BR>&gt; #include "itkImageFileReader.h"<BR>&gt; #include "itkImageFileWriter.h"<BR>&gt; #include "itkBinaryThresholdImageFilter.h"<BR>&gt; using namespace std;<BR>&gt; template &lt;class TInputImage,class TFeatureImage,class TOutputPixelType&gt;<BR>&gt; &nbsp;&nbsp; class ChanVese<BR>&gt; {<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; &nbsp;&nbsp; public:<BR>&gt; &nbsp;&nbsp;&nbsp; itkStaticConstMacro( ImageDimension, unsigned<BR>&gt; int,TInputImage::ImageDimension );<BR>&gt; &nbsp;&nbsp;&nbsp; typedef TFeatureImage FeatureImageType;<BR>&gt; &nbsp;&nbsp;&nbsp; typedef typename FeatureImageType::PixelType FeaturePixelType;<BR>&gt; &nbsp;&nbsp;&nbsp; typedef TInputImage InputImageType;<BR>&gt; &nbsp;&nbsp;&nbsp;
 typedef typename InputImageType::PixelType InputPixelType;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp; ChanVese()<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;"chan vesee desconstructed"&lt;&lt;std::endl;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp; ~ChanVese()<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp; {<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;"chan vesee desconstructed"&lt;&lt;std::endl;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt;<BR>&gt; &nbsp;&nbsp; } ;<BR>&gt; #endif<BR>&gt;<BR>&gt; ******************************************************<BR>&gt;<BR>&gt; --------------------------------------------------------------------------------------------------<BR>&gt; /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.txx:34: error:<BR>&gt; 'itk::Image&lt;TPixel, VImageDimension&gt;::Image() [with TPixel = short int,<BR>&gt; unsigned int VImageDimension
 = 3u]' is protected<BR>&gt; /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:35:<BR>&gt; error: within this context<BR>&gt; /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/test.cxx:490:<BR>&gt; instantiated from here<BR>&gt; /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h:287: error:<BR>&gt; 'itk::Image&lt;TPixel, VImageDimension&gt;::~Image() [with TPixel = short int,<BR>&gt; unsigned int VImageDimension = 3u]' is protected<BR>&gt; /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:35:<BR>&gt; error: within this context<BR>&gt; /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h: In destructor<BR>&gt; 'ChanVese&lt;TInputImage, TFeatureImage, TOutputPixelType&gt;::~ChanVese() [with<BR>&gt; TInputImage = itk::Image&lt;short int, 3u&gt;, TFeatureImage = itk::Image&lt;short<BR>&gt; int, 3u&gt;, TOutputPixelType = float]':<BR>&gt;
 /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/test.cxx:490:<BR>&gt; instantiated from here<BR>&gt; /home/gtao/tools/ITK/source_3.16/Code/Common/itkImage.h:287: error:<BR>&gt; 'itk::Image&lt;TPixel, VImageDimension&gt;::~Image() [with TPixel = short int,<BR>&gt; unsigned int VImageDimension = 3u]' is protected<BR>&gt; /home/gtao/code/Gui_Segmenation/chan_vesse/v1.5_tumor_pdfmap/source/algorithm/ChanVese.h:42:<BR>&gt; error: within this context<BR>&gt; ------------------------------------------------------------------------------------------------------<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; _____________________________________<BR>&gt; Powered by <A href="http://www.kitware.com/" target=_blank>www.kitware.com</A><BR>&gt;<BR>&gt; Visit other Kitware open-source projects at<BR>&gt; http://www.kitware.com/opensource/opensource.html<BR>&gt;<BR>&gt; Kitware offers ITK Training Courses, for more information visit:<BR>&gt;
 http://www.kitware.com/products/protraining.html<BR>&gt;<BR>&gt; Please keep messages on-topic and check the ITK FAQ at:<BR>&gt; http://www.itk.org/Wiki/ITK_FAQ<BR>&gt;<BR>&gt; Follow this link to subscribe/unsubscribe:<BR>&gt; http://www.itk.org/mailman/listinfo/insight-users<BR>&gt;<BR>&gt;<BR></DIV></DIV></div><br>



      </body></html>