[Insight-users] How to cast from RGB to short?
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Mon Aug 31 17:09:54 EDT 2009
Le 31 août 09 à 17:23, Michael Xanadu a écrit :
> Hi Gaëtan,
>
> thank you for your support. Actually, I thought that there's a
> difference in the number of segments between using <long> or
> colormapper for the output of watershed filter. It seemed to me that
> I receive more segments by using a RGB output. I found out that the
> problem lies in the viewer I use to watch the images. It had a wrong
> color level and showed the image to bright, so that a lot of
> segments disapeared.
> The clue of watershed is, that it delivers no single segment I'm
> looking for, but all segments it can find. To extract a single
> segment, I want to use Connected Threshold (with seed) afterwards.
> That was the reason I asked for help.
>
For a single object, I think it's easier (and more efficient) to
simply use a BinaryThresholdImageFilter, and to set both
UpperThreshold and LowerThresold to the pixel value of the object of
interest. The output is a simple binary image with only your object.
Gaëtan
> Regards, Michael
>
>
>
> 2009/8/31 Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr>
>
> 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
>
>
--
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/3f52c828/attachment.pgp>
More information about the Insight-users
mailing list