<DIV>
<DIV>Thanks jJulien it works,</DIV>
<DIV> </DIV>
<DIV>maybe if I can another question about the implementation of static methods in ITK...</DIV>
<DIV><BR>myFunction is a static function and it is define in a .h and implemented in a .txx <BR>so if I put everything in my .h like you said it works:</DIV>
<DIV><BR>typedef typename ImageType::Pointer InputImagePointer; <BR>static InputImagePointer::Pointer myFunction(...)<BR> {<BR>....<BR>}<BR>or if I don't want to use the typedef<BR>static typename TImage::Pointer myFunction(...)<BR> {<BR>....<BR>}<BR>and you guess that My Object is templated using TImage ...</DIV>
<DIV> </DIV>
<DIV>BUT, I don't know how to implement it in my .txx and just define the header function in my .h as we do usually (it never compile ....)</DIV>
<DIV><BR>.h<BR> typedef typename ImageType::Pointer InputImagePointer; <BR> static InputImagePointer::Pointer myFunction(...);<BR>.txx<BR>static InputImagePointer::Pointer myFunction(...)<BR>{</DIV>
<DIV>}<BR><BR>Thanks julien for help,</DIV>
<DIV>Lagaffe</DIV>
<DIV><BR><B><I>Julien Jomier <jjomier@cs.unc.edu></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi Lagaffe,<BR><BR>This is an issue with smart pointers.<BR>As you probably know smart pointers delete themselves when there are not <BR>assigned anymore.<BR>In your case, in myFunction(), the ImportFilter is creating a smart <BR>pointer as output image, but myFunction() is returning a raw pointer, <BR>which means that the reference count is not incremented and the output <BR>pointer is destroyed at the end of the myFunction() scope.<BR>An easy fix is to make your function return a smart pointer and assign a <BR>smart pointer in your main.<BR><BR>Something like:<BR><BR>ImageType::Pointer myFunction()<BR>{<BR>...<BR>return ImportFilter->GetOuput()<BR>}<BR><BR>and in your program:<BR><BR>typedef int PixelType;<BR>const int Dimension=2, Lx=7, Ly=5;<BR>typedef itk::Image < PixelType, Dimension > ImageType;<BR>ImageType::Pointer inputImage=myFunction(...);<BR><BR>Let us know if
that was the problem,<BR><BR>Julien<BR><BR>Mr Gaffe wrote:<BR>> hello,<BR>> <BR>> I try to build an itkImage with a function wich use an <BR>> importImageFilter; I can display my image inside my function (so the <BR>> importation pipeline is ok), but when I try to do the same thing in my <BR>> program using the return itkImage pointer it doesn't work !<BR>> <BR>> basically this is my code;<BR>> function:<BR>> <BR>> ImageType* myFunction(...)<BR>> ... build the image and Import it with itkImportImageFilter<BR>> ... I did an Update<BR>> I can display my Image using std::cout << ImportFilter->GetOuput() <BR>> <<?xml:namespace prefix = std /><std::endl OK.<br is importation the So ,>> <BR>> finally,I return the pointer:<BR>> return ImportFilter->GetOuput()<BR>> <BR>> In my program:<BR>> typedef int PixelType;<BR>> const int Dimension=2, Lx=7, Ly=5;<BR>> typedef itk::Image < PixelType, Dimension >
ImageType;<BR>> ImageType* inputImage=myFunction(...);<BR>> <BR>> When I try to display std:cout<<INPUTIMAGE <br a have I std::endl; <<>> pointer value and not all the usual image information .... and if I try <BR>> to use inputImage to do something it crash !<BR>> <BR>> I think, I am not using the good return type or something like that?<BR>> <BR>> thanks for help<BR>> lagaffe<BR>> <BR>> <BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos <BR>> mails !<BR>> Créez votre Yahoo! Mail <BR>> <HTTP: evt="25917/*http://fr.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions.yahoo.com/mail/creer28.html" fr.rd.yahoo.com *http: taglines mail><BR>> <BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> <BR>>
_______________________________________________<BR>> Insight-users mailing list<BR>> Insight-users@itk.org<BR>> http://www.itk.org/mailman/listinfo/insight-users<BR></BLOCKQUOTE></std::endl></DIV><p>
                <hr size=1>
Découvrez le nouveau Yahoo! Mail : <font color="red">250 Mo d'espace</font> de stockage pour vos mails !<br><a href="http://fr.rd.yahoo.com/mail/taglines/*http://fr.rd.yahoo.com/evt=25917/*http://fr.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions.yahoo.com/mail/creer28.html">Créez votre Yahoo! Mail</a>