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