<div dir="ltr">Massinissa,<div><br></div><div><br></div><div>What is wrong with the code in your example,</div><div>is that, in the expression</div><div><br></div><div><br></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.800000190734863px">   typedef itk::ImageIOBase::</span><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.800000190734863px">IOComponentType ScalarPixelType;</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">   const ScalarPixelType pixelTypeSource = imageIOsource-></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">GetComponentType();</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">The IOComponentType is actually an "enum".</span></div>
<div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">A type for which we have not consider it to be used as a valid image type.</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><font face="arial, sans-serif">Note that what GetComponentType() is returning is not a "pixel type",</font></div>
<div><font face="arial, sans-serif">but a "number" that refers to a "pixel type".  That is, it is just a label</font></div><div><font face="arial, sans-serif">that enumerates the potential expected pixel types.</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">The DefaultConvertPixelTraits, compilation error, in</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">   itk::</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">DefaultConvertPixelTraits<</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">PixelType>::ComponentType</span><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">happens because we have a set of traits defined for the expected </font></div><div><font face="arial, sans-serif">pixel types, c</font><span style="font-family:arial,sans-serif">ommon types such as : char, int, float....etc.</span></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">                    Not so for the IOComponentType enum.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">That is, the compiler is complaining about the use of</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">           itk::DefaultConvertPixelTraits< IOComponentType ></font></div><div><br></div><div>because it was expecting something like:</div>
<div><br></div><div><span style="font-family:arial,sans-serif">           itk::DefaultConvertPixelTraits< char ></span><br></div><div><span style="font-family:arial,sans-serif">           itk::DefaultConvertPixelTraits< short ></span><br>
</div><div><span style="font-family:arial,sans-serif">           itk::DefaultConvertPixelTraits< float ></span><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">           ...</span></div>
<div><span style="font-family:arial,sans-serif">           etc</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">For a full list of the expected types, please see:</span></div>
<div><span style="font-family:arial,sans-serif"><br></span></div><div><font face="arial, sans-serif">ITK/Modules/Core/Common/include/itkDefaultConvertPixelTraits.h</font></div><div><font face="arial, sans-serif"><br></font></div>
<div><font face="arial, sans-serif"><br></font></div><div><a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkDefaultConvertPixelTraits.h#L67">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkDefaultConvertPixelTraits.h#L67</a><span style="font-family:arial,sans-serif"><br>
</span></div><div><span style="font-family:arial,sans-serif"><div> 67 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) </div><div>...</div><div><br></div><div>and</div><div><br></div><div><a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkDefaultConvertPixelTraits.h#L95">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkDefaultConvertPixelTraits.h#L95</a><br>
</div><div><br></div></span></div><div><span style="font-family:arial,sans-serif"><div> 95 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float)</div><div> 96 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double)</div><div> 97 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int)</div>
<div> 98 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char)</div><div> 99 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short)</div><div>100 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int)</div><div>101 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char)</div>
<div>102 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char)</div><div>103 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short)</div><div>104 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long)</div><div>105 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long)</div>
<div>106 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long)</div><div>107 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long)</div><div>108 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool)</div><div><br></div></span></div>
<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><font face="arial, sans-serif">The way that the IOComponentTyep enum is expected to be used, is not by </font></div>
<div><font face="arial, sans-serif">taking it </font><span style="font-family:arial,sans-serif">directly as the pixel template type argument of an itk::Image<>,</span></div><div><font face="arial, sans-serif">but as the driving variable of a Switch() statement.</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Something like:</font></div><div><font face="arial, sans-serif"><br></font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">     switch(   imageIOSource->GetComponentType() )</font></div><div><font face="arial, sans-serif">     {</font></div><div><font face="arial, sans-serif">     case UCHAR:</font></div>
<div><font face="arial, sans-serif">          {</font></div><div><font face="arial, sans-serif">          typedef itk::Image< unsigned char, 3 > ImageType;</font></div><div><font face="arial, sans-serif">          ... etc...</font></div>
<div><font face="arial, sans-serif">         break;</font></div><div><font face="arial, sans-serif">         }</font></div><div><div><font face="arial, sans-serif">     case CHAR:</font></div><div><font face="arial, sans-serif">          {</font></div>
<div><font face="arial, sans-serif">          typedef itk::Image< char, 3 > ImageType;</font></div><div><font face="arial, sans-serif">          ... etc...</font></div><div><font face="arial, sans-serif">         break;</font></div>
<div><font face="arial, sans-serif">         }</font></div></div><div><div><font face="arial, sans-serif">     case UINT:</font></div><div><font face="arial, sans-serif">          {</font></div><div><font face="arial, sans-serif">          typedef itk::Image< unsigned int, 3 > ImageType;</font></div>
<div><font face="arial, sans-serif">          ... etc...</font></div><div><font face="arial, sans-serif">         break;</font></div><div><font face="arial, sans-serif">         }</font></div></div><div><font face="arial, sans-serif">     ...etc...</font></div>
<div><font face="arial, sans-serif">     }</font></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Regards,</span></div>
<div><br></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">    Luis</span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 10, 2014 at 1:34 AM, Massinissa Bandou <span dir="ltr"><<a href="mailto:Massinissa.Bandou@usherbrooke.ca" target="_blank">Massinissa.Bandou@usherbrooke.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dženan Zukić,<br>
<br>
I just want to know what's wrong with the code below because I have 5<br>
errors:<br>
<br>
<br>
Error   2       error C2146: syntax error : missing ';' before identifier<br>
'ComponentType' c:\program<br>
files\itk\include\itk-4.4\itkDefaultConvertPixelTraits.h        45      1<br>
TomoRegistration<br>
Error   4       error C2602:<br>
'itk::DefaultConvertPixelTraits<PixelType>::ComponentType' is not a member<br>
of a base class of 'itk::DefaultConvertPixelTraits<PixelType>'  c:\program<br>
files\itk\include\itk-4.4\itkDefaultConvertPixelTraits.h        45      1<br>
TomoRegistration<br>
Error   1       error C2838: 'ComponentType' : illegal qualified name in member<br>
declaration     c:\program<br>
files\itk\include\itk-4.4\itkDefaultConvertPixelTraits.h        45      1<br>
TomoRegistration<br>
Error   5       error C2868:<br>
'itk::DefaultConvertPixelTraits<PixelType>::ComponentType' : illegal syntax<br>
for using-declaration; expected qualified-name  c:\program<br>
files\itk\include\itk-4.4\itkDefaultConvertPixelTraits.h        45      1<br>
TomoRegistration<br>
Error   3       error C4430: missing type specifier - int assumed. Note: C++ does<br>
not support default-int c:\program<br>
files\itk\include\itk-4.4\itkDefaultConvertPixelTraits.h        45      1<br>
TomoRegistration<br>
<div class="im"><br>
<br>
<br>
<br>
        typedef itk::ImageIOBase::IOComponentType ScalarPixelType;<br>
</div>        itk::ImageIOBase::Pointer imageIOsource =<br>
itk::ImageIOFactory::CreateImageIO("writesource.mhd",itk::ImageIOFactory::ReadMode);<br>
        imageIOsource->SetFileName("writesource.mhd");<br>
        imageIOsource->ReadImageInformation();<br>
        const ScalarPixelType pixelTypeSource = imageIOsource->GetComponentType();<br>
<br>
        itk::ImageIOBase::Pointer imageIOtarget =<br>
itk::ImageIOFactory::CreateImageIO("writetarget.mhd",itk::ImageIOFactory::ReadMode);<br>
        imageIOtarget->SetFileName("writetarget.mhd");<br>
        imageIOtarget->ReadImageInformation();<br>
        const ScalarPixelType pixelTypeTarget = imageIOtarget->GetComponentType();<br>
<br>
       myClass* a= new myClass;<br>
       a->VolumeRegistration(pixelTypeSource,pixelTypeTarget);<br>
<br>
class myClass<br>
{<br>
        ....<br>
        template<typename pixelType1, typename pixelType2><br>
        void VolumeRegistration(pixelType1,pixelType2)<br>
        {<br>
                typedef itk::Image< pixelType1, 3 >  FixedImageType;<br>
                typedef itk::Image< pixelType2, 3 >  MovingImageType;<br>
        }<br>
};<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-users.7.n7.nabble.com/newbie-C-question-tp33081p33162.html" target="_blank">http://itk-users.7.n7.nabble.com/newbie-C-question-tp33081p33162.html</a><br>
<div class="im HOEnZb">Sent from the ITK - Users mailing list archive at Nabble.com.<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>
<a href="http://www.kitware.com/opensource/opensource.html" 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" 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" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
</div></div></blockquote></div><br></div>