[Insight-users] ImageMaskSpatialObject with non unsigned char PixelType?

Geoff Topping g_topping at hotmail.com
Thu Apr 23 18:04:12 EDT 2009


Hi Luke,

I considered just casting to unsigned char, but the file format I'm reading in (Analyze75) has a calibration / scale parameter that seems to get lost when casting to a signed integer type.  The absolute value of the scaled input image pixels is something like 0.001, so when cast to an integer type like signed int, or presumably unsigned char, I get all 0's.  This seems likely to cause problems when trying to use the image as a mask.  I realize this can probably be worked around as well, but having a float-compatible version of the ImageMaskSpatialObject class available by default would be much simpler and would avoid all these issues.

If memory footprint becomes a problem, then it seems like that would be the time to worry about reducing it, not ahead of time by unnecessarily restricting the acceptable input to the class.

Geoff

> Hi Geoff,
>
> I thought the same thing, if you template ImageMaskSpatialObject over
> the pixeltype and it would still work. However it is pretty simple to
> use an itkCastImageFilter.h to cast your image to unsigned char and this
> way has a smaller memory foot print.
>
> -Luke
>
> Geoff Topping wrote:
>> Hi,
>>
>> I'd like to do some masking of image registration using ImageMaskSpatialObject, but when I try to pass a
>>
>> itk::Image
>>
>> to
>>
>> itk::ImageMaskSpatialObject::SetImage()
>>
>>
>> I get compile errors along the lines of:
>>
>> error: no matching function for call to `itk::ImageMaskSpatialObject::SetImage(itk::Image*)'
>> itkImageSpatialObject.txx:281: note: candidates are: void itk::ImageSpatialObject::SetImage(const itk::Image*) [with unsigned int TDimension = 3u, TPixelType = unsigned char]
>>
>>
>> This is apparently because ImageMaskSpatialObject is defined as:
>>
>> class ImageMaskSpatialObject
>> : public ImageSpatialObject< TDimension, unsigned char>
>>
>>
>> So I'm wondering, is there a reason ImageMaskSpatialObject can only accept images with PixelType unsigned char? (Or should it be able to take images with PixelType float?)
>>
>> Shouldn't it be able to work with any PixelType for which NumericTraits::Zero is valid / defined?
>>
>> Can I just make my own version of ImageMaskSpatialObject that instantiates its ImageSpatialObject with float instead of unsigned char, or will this cause problems?
>>
>> Thanks,
>> Geoff Topping

_________________________________________________________________
Reinvent how you stay in touch with the new Windows Live Messenger.
http://go.microsoft.com/?linkid=9650731


More information about the Insight-users mailing list