<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"
 downloadurl="http://www.microsoft.com"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EstiloCorreo20
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.9pt 70.9pt 70.9pt 70.9pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=ES link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi Frederic,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>For storing the images
you can create a container of pointers to any of the base classes, for example
itk::ImageBase but you still need to know which image types you intend to use. You
can do something like<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>typedef
itk::Image&lt;unsigned char,2&gt;  UCharImageType;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>typedef itk::Image&lt;short,2&gt;              
ShortImageType;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>typedef
itk::ImageBase&lt;2&gt;                ImageBaseType;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>typedef
std::vector&lt;ImageBaseType::Pointer&gt;  ImageContainerType;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>ImageContainerType
imageContainer;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>ShortImageType::Pointer 
shortImage = ShortImageType::New();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>&#8230;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>do something with the
image<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>&#8230;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>// Store the image in the
container<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>imageContainer.push_back(
shortImage.GetPointer() );<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>UCharImageType::Pointer  ucharImage
= UCharImageType::New();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>&#8230;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>do something with the
image<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>&#8230;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>// Store the image in the
container<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>imageContainer.push_back(
ucharImage.GetPointer() );<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>The problem here is how
to down-cast the image to the specific type when retrieving it from the
container. One way is to use dynamic_cast or typeid to check among the types of
itk::Image that you might expect. For example :<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>UCharImageType::Pointer
ucharImage = dynamic_cast&lt; UCharImageType*&gt;( imageContainer[0].GetPointer()
);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>if(
ucharImage.IsNotNull() )<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>{<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>   // do something with
the ucharImage<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Of course there are more
complicated and clean approaches.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Hope that helps<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Ivan<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span lang=EN-GB
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>De:</span></font></b><font
size=2 face=Tahoma><span lang=EN-GB style='font-size:10.0pt;font-family:Tahoma'>
Frédéric Stevens [mailto:frederic.stevens@gmail.com] <br>
<b><span style='font-weight:bold'>Enviado el:</span></b> jueves, 24 </span></font><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>de mayo de
2007 15:07<br>
<b><span style='font-weight:bold'>Para:</span></b> <st1:PersonName
ProductID="Iván Macía" w:st="on">Iván Macía</st1:PersonName><br>
<b><span style='font-weight:bold'>Asunto:</span></b> Re: [Insight-users]
Changing InputPixelType in an easy way?</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>Hi Ivan,<br>
<br>
Thank you for answering. I am actually storing image in containers (importing
an image from IDL and exporting it back with filters applied on it). That is
why I need to have different kind of pixel and I intented to implement it such
as we don't need to know what the original pixel type is. <br>
<br>
Regards,<br>
<br>
Frédéric<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><span class=gmailquote><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>On 5/24/07, <st1:PersonName ProductID="Iván Macía"
w:st="on"><b><span style='font-weight:bold'>Iván Macía</span></b></st1:PersonName>
&lt;<a href="mailto:imacia@vicomtech.es">imacia@vicomtech.es</a>&gt; wrote:</span></font></span><o:p></o:p></p>

<div link=blue vlink=purple>

<div>

<p><font size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:navy'>Hi Frederic,</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>You cannot do what you intend. This is a C++
issue. With typedef you are defining new types which are valid only in the
space between the braces and those types no longer exist (go out of scope)
after them. So when you reach the point where you define the image types,
InputPixelType and OutputPixelType don't exist because they cannot be seen.</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>The class itk::Image is not intended for changing
the pixel type dinamically. If you need to use several pixel types then you
need to use several image types and you need to know them and define them
beforehand, that is at compile time. For example :</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>typedef itk::Image&lt;unsigned char,2&gt;
&nbsp;&nbsp;UCharImageType;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>typedef itk::Image&lt;short,2&gt;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShortImageType;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>and then use each image type where necessary. </span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>The only way of managing itk images independently
of the pixel type is using polymorphism by recurring to pointers to
itk::ImageBase which is depends only on the image dimension. But this is only
practical if you need to do something like storing images in containers. </span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Best regards</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Ivan</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p><b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
font-weight:bold'>De:</span></font></b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'> insight-users-bounces+imacia=<a
href="mailto:vicomtech.es@itk.org" target="_blank">vicomtech.es@itk.org</a>
[mailto:<a href="mailto:insight-users-bounces+imacia=vicomtech.es@itk.org"
target="_blank">insight-users-bounces+imacia=vicomtech.es@itk.org</a>] <b><span
style='font-weight:bold'>En nombre de </span></b>Frédéric Stevens<br>
<b><span style='font-weight:bold'>Enviado el:</span></b> jueves, 24 de mayo de
2007 14:27<br>
<b><span style='font-weight:bold'>Para:</span></b> <a
href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
<b><span style='font-weight:bold'>Asunto:</span></b> [Insight-users] Changing
InputPixelType in an easy way?</span></font><o:p></o:p></p>

</div>

<div><span id="q_112be2afdae105c9_1">

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p style='margin-bottom:12.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Hi,<br>
<br>
I was wondering if you could change the InputPixelType easily ? <br>
I have tried something like :<br>
<br>
&nbsp; &nbsp;&nbsp; int test = 1;&nbsp;&nbsp;&nbsp; // just to be sure it
enters the first if for InputPixeltype to be defined<br>
&nbsp;&nbsp;&nbsp;&nbsp; if( test == 1)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef&nbsp; unsigned char
InputPixelType; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef&nbsp; unsigned char
OutputPixelType; <br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef&nbsp; short InputPixelType; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef&nbsp; short OutputPixelType; <br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;<br>
typedef itk::Image&lt; InputPixelType,&nbsp; 2 &gt;&nbsp;&nbsp; InputImageType;<br>
typedef itk::Image&lt; OutputPixelType, 2&gt;&nbsp;&nbsp; OutputImageType;<br>
<br>
But It doesn't work: gives that error &quot; Error&nbsp;&nbsp;&nbsp;
4&nbsp;&nbsp;&nbsp; error C2065: 'InputPixelType' : undeclared
identifier&nbsp;&nbsp;&nbsp;
e:\tmp\Imageimport\binarytest.cxx&nbsp;&nbsp;&nbsp; 62&nbsp;&nbsp;&nbsp; &quot;
<br>
If i put directly one type it works, but if i put an &quot;if&quot;, even
though I am sure in goes in, the InputPixelType isn't known. Could you explain
me why it doesn't recognize it ?<br>
<br>
Thank you in advance, <br>
Regards,<br>
<br>
Frédéric<br>
<br>
<br>
<br>
<o:p></o:p></span></font></p>

</div>

<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'></span>No
virus found in this incoming message.<br>
Checked by AVG Free Edition.<br>
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007 15:59</span></font><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>No virus
found in this outgoing message.<br>
Checked by AVG Free Edition.<br>
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007 15:59</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>No virus
found in this incoming message.<br>
Checked by AVG Free Edition.<br>
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007 15:59</span></font><o:p></o:p></p>

</div>

</body>

</html>
<BR>

<P><FONT SIZE=2>No virus found in this outgoing message.<BR>
Checked by AVG Free Edition.<BR>
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007 15:59<BR>
</FONT> </P>