[Insight-users] How to cast from RGB to short?
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Mon Aug 31 10:11:16 EDT 2009
Le 31 août 09 à 15:33, Michael Xanadu a écrit :
> Hi,
>
> I've got a watershed filtered image processed by a colormapper. So
> it's an image of type:
>
> typedef itk::RGBPixel<short> RGBPixelType;
> typedef itk::Image<RGBPixelType, 2> RGBImageType;
>
> Now I want to filter that image with a connected threshold filter,
> because I need it this way.
> But ConnectedThresholdImageFilter can't process such RGB images.
> I tryed to convert the image into a short type by using
> CastImageFilter, too.
> But I always get:
>
> error C2440: 'static_cast' : cannot convert from
> 'itk::RGBPixel<TComponent>' to 'short'
>
> So how can I cast from RGB to short? Or how to filter a RGB image
> with a connected threshold filter?
>
You can extract one of the channels with
VectorIndexSelectionCastImageFilter or go to an intensity image with
RGBToLuminanceImageFilter, but I doubt that's what you want. The color
image is only a representation of the watershed output easier to read
for humans, but not for computer. If you want to work on the output of
the watershed, it's better to not use a color mapper, but directly on
the output image of the watershed - the image should be of type
itk::Image< unsigned long, 2 >.
And even if you don't use a color mapper, it may not be a good idea to
process the output of the watershed filter (a labeled image) with a
filter (ConnectedThresholdImageFilter) made to work on a grayscale
images.
Can you explain what you want to achieve?
Regards,
Gaëtan
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr http://www.itk.org
http://www.mandriva.org http://www.bepo.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090831/4a157ccd/attachment-0001.pgp>
More information about the Insight-users
mailing list