[Insight-users] an issue with Spa
tialObjectToImageStatist icsCalculator an d ImageMaskSpatialObject.
kurt
kurtzhao at yeah.net
Thu Jul 13 11:17:32 EDT 2006
Hi Julien,
Thanks for the prompt fix. But I had a problem to build the application. I got an error msg below. I am using Visual Studio 2005 on WinXP Pro SP2.
Thanks!
Kurt Zhao
e:\work\insight\code\basicfilters\itkSpatialObjectToImageStatisticsCalculator.txx(126) : error C2440: 'static_cast' : cannot convert from 'itk::SmartPointer<TObjectType>' to 'MaskSOType *'
with
[
TObjectType=itk::EllipseSpatialObject<3>
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
e:\work\insight\code\basicfilters\itkSpatialObjectToImageStatisticsCalculator.txx(95) : while compiling class template member function 'void itk::SpatialObjectToImageStatisticsCalculator<TInputImage,TInputSpatialObject>::Update(void)'
with
[
TInputImage=ImageType,
TInputSpatialObject=EllipseType
]
..\..\nirl\LesionSampler\main.cxx(163) : see reference to class template instantiation 'itk::SpatialObjectToImageStatisticsCalculator<TInputImage,TInputSpatialObject>' being compiled
with
[
TInputImage=ImageType,
TInputSpatialObject=EllipseType
]
>
> Hi Kurt,
Thanks for the report.
The problem was that the MaskImageSpatialObject can be sparse, therefore
the Flood Filled iterator could not work in this case. I've put a fix in
the cvs repository.
Let me know if you still have any issues with this calculator,
Julien
> kurt wrote:
> > Hello all,
> >
> > I'd like to compute the mean and standard deviation of a part of an image.
> > That part is described by an ImageMaskSpatialObject.
> >
> > The following program is what I came up with, but it behaves strangely.
> > the output is
> >
> > Sample mean = [-1.#IND]
> > Sample covariance = -0
> >
> > I think probably something wrong with the iterator, because
> > m_NumberOfPixels: 0
> >
> > Also, the calculator worked fine if I use a ellipse as an input.
> >
> > Any help/ideas are much appreciated, here is my code, the data is
> > available at http://www.duke.edu/~kurtzhao/data.zip:
> >
> > int TestSampler( )
> > {
> > typedef double PixelType ;
> > typedef unsigned char OverlayPixelType ;
> > typedef itk::Image < PixelType, 3 > ImageType;
> > typedef itk::Image < OverlayPixelType, 3 > OverlayType;
> >
> > typedef itk::ImageFileReader < ImageType > ImageReaderType;
> > ImageReaderType::Pointer imageReader = ImageReaderType::New();
> > imageReader -> SetFileName( "image.mhd" ) ;
> > try
> > {
> > imageReader -> Update();
> > }
> > catch( ... )
> > {
> > std::cout << "Problems reading image file " <<
> > imageReader-> GetFileName ( ) << std::endl;
> > return EXIT_FAILURE ;
> > }
> >
> > typedef itk::ImageFileReader < OverlayType > OverlayReaderType;
> > OverlayReaderType::Pointer overlayReader = OverlayReaderType::New();
> > overlayReader -> SetFileName( "overlay.mhd" ) ;
> > try
> > {
> > overlayReader -> Update();
> > }
> > catch( ... )
> > {
> > std::cout << "Problems reading overlay file " <<
> > overlayReader-> GetFileName ( ) << std::endl;
> > return EXIT_FAILURE;
> > }
> >
> > ImageType::Pointer image = imageReader -> GetOutput ( ) ;
> >
> > OverlayType::Pointer overlay = overlayReader -> GetOutput ( ) ;
> >
> > ImageType::IndexType indexInside ;
> > indexInside [ 0 ] = 140 ;
> > indexInside [ 1 ] = 122 ;
> > indexInside [ 2 ] = 24 ;
> >
> > typedef itk::ImageMaskSpatialObject<3> ImageMaskSpatialObject;
> > ImageMaskSpatialObject::Pointer maskSO = ImageMaskSpatialObject::New();
> > maskSO->SetImage( overlay );
> > //maskSO -> Print ( std::cout ) ;
> > ImageMaskSpatialObject::PointType inside ;
> > ImageMaskSpatialObject::PointType outside ;
> > for ( int i = 0 ; i < 3 ; i ++)
> > {
> > inside [ i ] = indexInside [ i ] *
> > image -> GetSpacing ( ) [ i ] ;
> > }
> > outside [ 0 ] = 197 ;
> > outside [ 1 ] = 65 ;
> > outside [ 2 ] = 14 ;
> > std::cout << "Is my point " << indexInside << " inside my mask image? "
> > << (int ) overlay -> GetPixel ( indexInside ) << std::endl;
> > std::cout << "Is my point " << inside << " inside my mask? "
> > << maskSO->IsInside(inside) << std::endl;
> > std::cout << "Is my point " << outside << " outside my mask? "
> > << !maskSO->IsInside(outside) << std::endl;
> >
> >
> > typedef itk::SpatialObjectToImageStatisticsCalculator<
> > ImageType, ImageMaskSpatialObject> CalculatorType;
> > CalculatorType::Pointer calculator = CalculatorType::New();
> > calculator->SetImage(image);
> > calculator->SetSpatialObject( maskSO );
> > calculator->Update();
> > calculator->Print ( std::cout );
> > std::cout << "Sample mean = " << calculator->GetMean() << std::endl ;
> > std::cout << "Sample covariance = " << calculator->GetCovarianceMatrix();
> > return EXIT_SUCCESS ;
> > }
> > int main(int argc, char **argv)
> > {
> > //itkEllipseBoundaryToImageFilterTest ( ) ;
> > TestSampler ( ) ;
> >
> > return 1 ;
> > }
> >
> > Best Regards
> > Kurt Zhao
> >
> >
> >
> >
> >
> >
> > 你 不 想 试 试 今 夏 最 “酷” 的 邮 箱 吗 ?
> > 蕴 涵 中 华 传 统 文 化 于 世 界 一 流 科 技 之 中,创 新 Ajax 技 术,
> > 126 “D 计 划”火 热 体 验 中 ! <http://www.126.com/>
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060713/3f4d461d/attachment-0001.html
More information about the Insight-users
mailing list