<DIV>Thanks again julien, the definition is quite simple and obvious I understand why I spend all the last few years with JAVA ;-)</DIV>
<DIV> </DIV>
<DIV>I look in the ImageToImageFilter to understand the strategy used by ITK to return an image after processing. The return type is an OutputTypeImage and not a Pointer, so I confuse because I don't know when and how to return an ImageType and when I have to return a Pointer (as I did in myFunction) ?</DIV>
<DIV> </DIV>
<DIV>Lagaffe</DIV>
<DIV><BR><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>I assume your function is inside the class MyObject.<BR><BR>In your .h:<BR><BR>typedef TImage ImageType;<BR>typedef typename ImageType::Pointer InputImagePointer;<BR>static InputImagePointer myFunction(...);<BR><BR>In your .txx:<BR><BR>template<CLASS TImage><BR>MyObject<TIMAGE>::InputImagePointer<BR>MyObject<TIMAGE><BR>::myFunction(...)<BR>{<BR>....<BR>}<BR><BR>hope that helps,<BR><BR>Julien<BR><BR>Mr Gaffe wrote:<BR>> Thanks jJulien it works,<BR>> <BR>> maybe if I can another question about the implementation of static <BR>> methods in ITK...<BR>> <BR>> myFunction is a static function and it is define in a .h and implemented <BR>> in a .txx<BR>> so if I put everything in my .h like you said it works:<BR>> <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 ...<BR>> <BR>> BUT, I don't know how to implement it in my .txx and just define the <BR>> header function in my .h as we do usually (it never compile ....)<BR>> <BR>> .h<BR>> typedef typename ImageType::Pointer InputImagePointer;<BR>> static InputImagePointer::Pointer myFunction(...);<BR>> .txx<BR>> static InputImagePointer::Pointer myFunction(...)<BR>> {<BR>> }<BR>> <BR>> Thanks julien for help,<BR>> Lagaffe<BR>> <BR>> */Julien Jomier <JJOMIER@CS.UNC.EDU>/* wrote:<BR>> <BR>> Hi Lagaffe,<BR>> <BR>> This is an issue with smart pointers.<BR>> As you probably know smart pointers delete themselves when there are<BR>> 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<BR>> 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 k! now 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<BR>> 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>> > <<BR>> ><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, Dimensi! on > ImageType;<BR>> > ImageType* inputImage=myFunction(...);<BR>> ><BR>> > When I try to display
std:cout<<BR>> <<>> pointer value and not all the usual image information .... and<BR>> 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>> ------------------------------------------------------------------------<BR>> > Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage<BR>> pour vos<BR>> > mails !<BR>> > Créez votre Yahoo! Mail<BR>> ><BR>> ><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>>
<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: 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"><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><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>