<div dir="ltr">Hi Matt,<div><br></div><div>Let me try it this way. I tried all the following prototypes, but none of them worked. Probably some C++ syntax problem...</div><div><br></div><div><div>template <class T1, int T2></div><div>extern int ItkToAvs(AVSfield** ppAvs, itk::Image<T1, T2> pItkImage);</div><div><br></div><div>template <int T2></div><div>extern int ItkToAvs(AVSfield** ppAvs, itk::Image<fPixelType, T2> pItkImage);</div><div><br></div><div>extern int ItkToAvs(AVSfield** ppAvs, itk::Image<fPixelType, 3> pItkImage);</div><div><br></div><div>template< typename TImage></div><div>extern int ItkToAvs(AVSfield** ppAvs, TImage* pItkImage);</div><div><br></div><div>template< typename TPixel, unsigned int VImageDimension></div><div>extern int ItkToAvs(AVSfield** ppAvs, const itk::Image<TPixel, VImageDimension> pItkImage);</div><div><br></div><div>template< typename TObjectType></div><div>extern int ItkToAvs(AVSfield** ppAvs, const itk::SmartPointer<TObjectType> pItkImage);</div></div><div><br></div><div>The first parameter is the output of the function. The second parameter is <b>any</b> itk image.</div><div>As you can see, I don't know what I'm doing... Any idea what a good prototype would be?</div><div><br></div><div>Greetings,</div><div>Lambert</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 10, 2016 at 5:40 PM, Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Lambert,<br>
<br>
A function prototype without templates would be run-time to run-time<br>
type comparison and conversion.  The example shows how to do run-time<br>
to compile-time comparison, and it is relevant to both in-memory and<br>
file conversion.<br>
<br>
HTH,<br>
Matt<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Mar 10, 2016 at 11:28 AM, Lambert Zijp <<a href="mailto:ljzijp@gmail.com">ljzijp@gmail.com</a>> wrote:<br>
> Hi Sarthak,<br>
> There is no file I/O involved. It is about conversion in memory. In my<br>
> original post, MyFormat is a struct containing things like pixeltype and<br>
> number of dimensions and a couple of pointers to the pixels, the sizes of<br>
> the dimensions, and the coordinates. Conversion from MyFormat to itk, I got<br>
> more or less working. Now I want to convert from itk to MyFormat. A function<br>
> prototype is needed...<br>
><br>
> Greetings,<br>
> Lambert<br>
><br>
> On Thu, Mar 10, 2016 at 5:02 PM, Scapegoat Sarthak<br>
> <<a href="mailto:scapegoat.sarthak@gmail.com">scapegoat.sarthak@gmail.com</a>> wrote:<br>
>><br>
>> Hi Lambert,<br>
>><br>
>> What you could do is to make a function what just takes in a file name as<br>
>> input and call the templated ITK function inside as an inline function.<br>
>> There is no way I know to do I/O in ITK without using templates.<br>
>><br>
>> Best,<br>
>> Sarthak<br>
>><br>
>><br>
>> On 10 March 2016 at 10:55, Lambert Zijp <<a href="mailto:ljzijp@gmail.com">ljzijp@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi Scapegoat,<br>
>>> Thank you for responding. What would the function prototype then be (of<br>
>>> function that accepts any itk image. I mean, the syntax, preferably not<br>
>>> templated)?<br>
>>> Because I deal mostly with 3D or 4D signed short pixels (medical images),<br>
>>> I keep them as they are: half the memory consumption and easier histogram<br>
>>> computations.<br>
>>><br>
>>> Greetings,<br>
>>> Lambert<br>
>>><br>
>>> On Thu, Mar 10, 2016 at 4:35 PM, Scapegoat Sarthak<br>
>>> <<a href="mailto:scapegoat.sarthak@gmail.com">scapegoat.sarthak@gmail.com</a>> wrote:<br>
>>>><br>
>>>> I would advice you to perform a check on the image dimensions (2 or 3)<br>
>>>> and keep the pixel type as float throughout. In any case you will be doing<br>
>>>> computation so the extra memory is going to be helpful.<br>
>>>><br>
>>>><br>
>>>> On 10 March 2016 at 10:28, Matt McCormick <<a href="mailto:matt.mccormick@kitware.com">matt.mccormick@kitware.com</a>><br>
>>>> wrote:<br>
>>>>><br>
>>>>> Hi Lambert,<br>
>>>>><br>
>>>>> This example shows how to read in an unknown image type. It<br>
>>>>> demonstrates how to go between run-time type specification and the<br>
>>>>> compile-image type specification of ITK.<br>
>>>>><br>
>>>>><br>
>>>>> <a href="http://itk.org/ITKExamples/src/IO/ImageBase/ReadUnknownImageType/Documentation.html" rel="noreferrer" target="_blank">http://itk.org/ITKExamples/src/IO/ImageBase/ReadUnknownImageType/Documentation.html</a><br>
>>>>><br>
>>>>> This approach could be used for your problem.<br>
>>>>><br>
>>>>> HTH,<br>
>>>>> Matt<br>
>>>>><br>
>>>>> On Thu, Mar 10, 2016 at 9:56 AM, Lambert Zijp <<a href="mailto:ljzijp@gmail.com">ljzijp@gmail.com</a>> wrote:<br>
>>>>> > Dear itk users,<br>
>>>>> > I'm new to itk and also not very proficient in C++...<br>
>>>>> > I want to try some deformable registration methods implemented in<br>
>>>>> > itk, and<br>
>>>>> > need to convert my own format of images and volumes to itk, and back.<br>
>>>>> > For conversion to itk, I use 'ImportImageFilter', because I do not<br>
>>>>> > want to<br>
>>>>> > make a copy of the pixels/voxels.<br>
>>>>> > Converting itk images and volumes back to my own format, is giving me<br>
>>>>> > a<br>
>>>>> > headache; I'm confused about 'Image', SmartPointer and ConstPointer<br>
>>>>> > and<br>
>>>>> > template stuff.<br>
>>>>> > Could you get me started by suggesting me a function prototype?<br>
>>>>> ><br>
>>>>> > Something like:<br>
>>>>> > int ItkToMyFormat(MyFormat** ppMyFormat, itk::Image* pItkImage);<br>
>>>>> ><br>
>>>>> > The ItkImage can be any pixeltype, any dimension, and vector images<br>
>>>>> > should<br>
>>>>> > also be accepted by the conversion routine. In that conversion<br>
>>>>> > function, and<br>
>>>>> > need to be able to put a switch on pixeltype and number of<br>
>>>>> > dimensions.<br>
>>>>> ><br>
>>>>> > Greetings,<br>
>>>>> > Lambert<br>
>>>>> ><br>
>>>>> > _____________________________________<br>
>>>>> > Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
>>>>> ><br>
>>>>> > Visit other Kitware open-source projects at<br>
>>>>> > <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>>>> ><br>
>>>>> > Kitware offers ITK Training Courses, for more information visit:<br>
>>>>> > <a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
>>>>> ><br>
>>>>> > Please keep messages on-topic and check the ITK FAQ at:<br>
>>>>> > <a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>>>>> ><br>
>>>>> > Follow this link to subscribe/unsubscribe:<br>
>>>>> > <a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
>>>>> ><br>
>>>>> _____________________________________<br>
>>>>> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
>>>>><br>
>>>>> Visit other Kitware open-source projects at<br>
>>>>> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>>>><br>
>>>>> Kitware offers ITK Training Courses, for more information visit:<br>
>>>>> <a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
>>>>><br>
>>>>> Please keep messages on-topic and check the ITK FAQ at:<br>
>>>>> <a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>>>>><br>
>>>>> Follow this link to subscribe/unsubscribe:<br>
>>>>> <a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
>>>><br>
>>>><br>
>>><br>
>><br>
><br>
</div></div></blockquote></div><br></div>