<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=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
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.EstiloCorreo17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
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=ES link=blue vlink=purple><div class=WordSection1><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'>Hi all,<o:p></o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>I am calculating the typical registration example from one white point to the letter 'C' over a black background.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>In the first iteration of my program ( numiter = 1 ), it calculates the gradient from a 'reader' and the result is correct. In the next iteration ( numiter = 2 ) the result is not completely correct, in the borders of the image there are some wrong values, despite the gradient values in the centre of the image are correct. <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>Below is my code, I really need to fix this problem soon and I have spent some days without results! Any help would be really nice.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'>double</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> *dT1 = <span style='color:blue'>new</span> <span style='color:blue'>double</span>[ancho*alto]; <span style='color:green'>// width * height<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'>double</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> *dT2 = <span style='color:blue'>new</span> <span style='color:blue'>double</span>[ancho*alto]; <span style='color:green'>// width * height<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:green'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:green'>// Definition of the input image container and output(gradient)<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>GradientFilterType::Pointer gradientFilter = GradientFilterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> ImageType::Pointer im_T = ImageType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>if</span> (numIter == 1){ <span style='color:green'>// The first time read image from reader<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> gradientFilter->SetInput(reader_T->GetOutput());<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>else</span> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:green'>// Definition of the basic parameters of the image that contents the input data</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> ImageType::IndexType start;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> start[0] = 0 ; <span style='color:green'>// first index on X<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> start[1] = 0 ; <span style='color:green'>// first index on Y<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> ImageType::SizeType size;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> size[0] = ancho; <span style='color:green'>// size along X<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> size[1] = alto ; <span style='color:green'>// size along Y<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> ImageType::RegionType region;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> region.SetSize(size);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> region.SetIndex(start);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> im_T->SetRegions(region);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> im_T->Allocate(); <span style='color:green'>// allocate the image</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> double2itk ( T , &im_T); <span style='color:green'>// T(double*) --> im_T(itk::Image)<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> gradientFilter->SetInput(im_T);<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:10.0pt;line-height:115%'><span lang=EN-US style='font-size:10.0pt;line-height:115%;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:10.0pt;line-height:115%'><span lang=EN-US style='font-size:10.0pt;line-height:115%;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:green'>// Common part<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> gradientFilter->SetUseImageSpacingOff(); <span style='color:green'>// for derivation in isotropic pixel space<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> gradientFilter->Update();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> SelectionFilterType::Pointer componentExtractor_x = SelectionFilterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> SelectionFilterType::Pointer componentExtractor_y = SelectionFilterType::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> </span><span style='font-size:10.0pt;font-family:"Courier New"'>componentExtractor_x->SetIndex(0);<span style='color:green'>// componente x<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> componentExtractor_y->SetIndex(1);<span style='color:green'>// componente y<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:green'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>componentExtractor_x->SetInput(gradientFilter->GetOutput());<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> componentExtractor_y->SetInput(gradientFilter->GetOutput());<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> componentExtractor_x->Update();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> componentExtractor_y->Update();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> dT2 = itk2double(componentExtractor_x->GetOutput(),dT2,ancho,alto); <span style='color:green'>// X-Component of the gradient<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> dT1 = itk2double(componentExtractor_y->GetOutput(),dT1,ancho,alto); <span style='color:green'>// Y-Component of the gradient<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:green'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>Thanks!<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>Antonio Gómez Barquero<o:p></o:p></span></p><p class=MsoNormal><span lang=ES-TRAD style='font-size:8.0pt;mso-fareast-language:ES'>Ingeniero de Telecomunicaciones -Becario Investigador asociado a Actividades de I+D+I <o:p></o:p></span></p><p class=MsoNormal><span lang=ES-TRAD style='font-size:8.0pt;mso-fareast-language:ES'>GTTS ( Grupo de Tratamiento y Teoría de la Señal)[ </span><span style='font-size:8.0pt;mso-fareast-language:ES'><a href="http://gtts.upct.es/"><span style='color:blue'>http://gtts.upct.es/</span></a></span><span lang=ES-TRAD style='font-size:8.0pt;mso-fareast-language:ES'>]<o:p></o:p></span></p><p class=MsoNormal><span lang=ES-TRAD style='font-size:8.0pt;mso-fareast-language:ES'>UPCT (Universidad Politécnica de Cartagena)[ </span><span style='font-size:8.0pt;mso-fareast-language:ES'><a href="http://www.upct.es/"><span style='color:blue'>http://www.upct.es/</span></a>]</span><span lang=ES-TRAD style='font-size:8.0pt;mso-fareast-language:ES'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>