[Insight-users] Changing InputPixelType in an easy way?
Iván Macía
imacia at vicomtech.es
Thu May 24 09:00:53 EDT 2007
Hi Frederic,
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 dont exist because they cannot be seen.
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 :
typedef itk::Image<unsigned char,2> UCharImageType;
typedef itk::Image<short,2> ShortImageType;
and then use each image type where necessary.
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.
Best regards
Ivan
_____
De: insight-users-bounces+imacia=vicomtech.es at itk.org
[mailto:insight-users-bounces+imacia=vicomtech.es at itk.org] En nombre de
Frédéric Stevens
Enviado el: jueves, 24 de mayo de 2007 14:27
Para: Insight-users at itk.org
Asunto: [Insight-users] Changing InputPixelType in an easy way?
Hi,
I was wondering if you could change the InputPixelType easily ?
I have tried something like :
int test = 1; // just to be sure it enters the first if for
InputPixeltype to be defined
if( test == 1)
{
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
}
else
{
typedef short InputPixelType;
typedef short OutputPixelType;
}
typedef itk::Image< InputPixelType, 2 > InputImageType;
typedef itk::Image< OutputPixelType, 2> OutputImageType;
But It doesn't work: gives that error " Error 4 error C2065:
'InputPixelType' : undeclared identifier
e:\tmp\Imageimport\binarytest.cxx 62 "
If i put directly one type it works, but if i put an "if", even though I am
sure in goes in, the InputPixelType isn't known. Could you explain me why it
doesn't recognize it ?
Thank you in advance,
Regards,
Frédéric
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007
15:59
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.7/816 - Release Date: 23/05/2007
15:59
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070524/e599b572/attachment.html
More information about the Insight-users
mailing list