<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Malgun Gothic";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:NSimSun;
        panose-1:2 1 6 9 3 1 1 1 1 1;}
@font-face
        {font-family:NSimSun;
        panose-1:2 1 6 9 3 1 1 1 1 1;}
@font-face
        {font-family:"\@Malgun Gothic";}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><div><p class=MsoNormal><span style='color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Is my question too difficult? Please do me a favor to check my question. Any idea would be very much appreciated. Or except ITK Software Guide, is there any other manual which introduces the itkGradientMagnitudeRecursiveGaussianImageFilter in very detail, including pipeline and formulas?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Thank you so much!<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Best,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Xiaopeng</span><span style='font-family:"Arial","sans-serif";color:#1F497D'><o:p></o:p></span></p></div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> insight-users-bounces@itk.org [mailto:insight-users-bounces@itk.org] <b>On Behalf Of </b>Xiaopeng Yang<br><b>Sent:</b> Monday, December 17, 2012 9:14 PM<br><b>To:</b> insight-users@itk.org; 'Insight Developers'<br><b>Subject:</b> [Insight-users] What is the pipeline inside the itkGradientMagnitudeRecursiveGaussianImageFilter?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Dear All,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am trying to look through the itkGradientMagnitudeRecursiveGaussianImageFilter to figure out the pipeline of this filter to visualize the computation process of image gradient calculation from a CT volume dataset using this filter. However, the source code of this filter makes me confused about the pipeline in this filter due to my limited programming skill.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This filter consists of two major steps as far as I know: 1) image smoothing using itkRecursiveGaussianImageFilter, and 2) image gradient calculation using a finite difference method (Does anybody know what formula was used for the finite difference method? I checked the source code but could not get it). <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For step 1, I wrote a code to get the smoothed image. But I am not sure whether my code would get the same smoothed image as itkGradientMagnitudeRecursiveGaussianImageFilter or not. Please check my code and point out which part I missed or is not correct. Thank you very much!<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun;color:green'>// Setup types<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::Image< <span style='color:blue'>float</span>, 3 > FloatImageType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::Image< <span style='color:blue'>unsigned</span> <span style='color:blue'>char</span>, 3 > UnsignedCharImageType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::ImageFileReader< FloatImageType > readerType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::RecursiveGaussianImageFilter<<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> FloatImageType, FloatImageType > filterType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:green'>// Create and setup a reader<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> readerType::Pointer reader = readerType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> reader->SetFileName( <span style='color:#A31515'>"D:/Hybrid Method/Hybrid/LEJ/Diffusion_filter/3D.dcm"</span> );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:green'>// Create and setup a gaussian filter<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> filterType::Pointer m_DerivativeFilter = filterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_DerivativeFilter->SetInput( reader->GetOutput() );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:green'>//m_DerivativeFilter->SetDirection(1); // "x" axis<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_DerivativeFilter->SetFirstOrder();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_DerivativeFilter->SetSigma(1.3);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_DerivativeFilter->SetNormalizeAcrossScale(<span style='color:blue'>true</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_DerivativeFilter->ReleaseDataFlagOn();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> filterType::Pointer m_SmoothingFilters[2]; <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>for</span>( <span style='color:blue'>unsigned</span> <span style='color:blue'>int</span> i = 0; i< 2; i++ )<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[ i ] = filterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[ i ]->SetZeroOrder();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[ i ]->SetNormalizeAcrossScale( <span style='color:blue'>true</span> ); <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[ i ]->SetSigma( 1.3 );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[0]->SetInput( m_DerivativeFilter->GetOutput() );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>for</span>( <span style='color:blue'>unsigned</span> <span style='color:blue'>int</span> i = 1; i< 2; i++ )<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> m_SmoothingFilters[ i ]->SetInput( m_SmoothingFilters[i-1]->GetOutput() );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::CastImageFilter< FloatImageType, UnsignedCharImageType ><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> CastFilterType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> CastFilterType::Pointer caster1 = CastFilterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> caster1->SetInput( m_SmoothingFilters[1]->GetOutput() ); <span style='color:green'><o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> <span style='color:blue'>typedef</span> itk::ImageFileWriter< UnsignedCharImageType > WriterType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> WriterType::Pointer writer1 = WriterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> writer1->SetFileName( <span style='color:#A31515'>"RecusiveGaussian.dcm"</span> );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> writer1->SetInput(caster1->GetOutput());<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'> writer1->Update();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:9.0pt'><span style='font-size:9.0pt;font-family:NSimSun;color:blue'>return</span><span style='font-size:9.0pt;font-family:NSimSun'> EXIT_SUCCESS;<o:p></o:p></span></p><p class=MsoNormal style='text-indent:9.0pt'><span style='font-size:9.0pt;font-family:NSimSun'><o:p> </o:p></span></p><p class=MsoNormal>Best regards,<o:p></o:p></p><p class=MsoNormal>Xiaopeng<o:p></o:p></p></div></body></html>