<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16722"></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face=Verdana><SPAN 
class=420542514-13042011>You can use the </SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face=Verdana><SPAN 
class=420542514-13042011></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT color=#0000ff><SPAN class=420542514-13042011><FONT 
color=#808080><FONT color=#808080>
<P><FONT size=2 face=Verdana>itkMemoryProbesCollectorBase</FONT></P>
<P><SPAN class=420542514-13042011><FONT color=#0000ff size=2 face=Verdana>to 
watch your memory. I also use time probe. Define following as global on top of 
your code:</FONT></SPAN></P>
<P><SPAN class=420542514-13042011><FONT color=#808080><FONT color=#808080><FONT 
size=2>itk::MemoryProbesCollectorBase g_oMemorymeter;</FONT></P><FONT 
color=#808080><FONT color=#808080 size=2>
<P>itk::TimeProbesCollectorBase g_oChronometer; </P></FONT></FONT><FONT 
color=#808080><FONT color=#808080>
<P><FONT size=2>#define itkProbesStart( text ) std::cout &lt;&lt; "Begin: " 
&lt;&lt; text &lt;&lt; std::endl; g_oChronometer.Start( text ); 
g_oMemorymeter.Start( text )</FONT></P>
<P><FONT size=2>#define itkProbesStop( text ) std::cout &lt;&lt; "End: " 
&lt;&lt; text &lt;&lt; std::endl; g_oChronometer.Stop( text ); 
g_oMemorymeter.Stop( text )</FONT></P>
<P><FONT size=2>#define itkProbesReport( stream ) g_oChronometer.Report( stream 
); g_oMemorymeter.Report( stream )</FONT></P></FONT></FONT>
<P><FONT color=#0000ff size=2 face=Verdana><SPAN class=420542514-13042011>In 
your code you can use it like this</SPAN></FONT></P><FONT color=#0000ff><SPAN 
class=420542514-13042011>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesStart(&nbsp;<SPAN 
class=420542514-13042011>"Step1"</SPAN>)</FONT></P>
<P><SPAN class=420542514-13042011><FONT color=#808080 size=2 face=Verdana>do 
something</FONT></SPAN></P>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesStart(&nbsp;<SPAN 
class=420542514-13042011>"Step1-1"</SPAN>)</FONT></P>
<P><SPAN class=420542514-13042011><FONT color=#808080 size=2 face=Verdana>do 
something</FONT></SPAN></P><SPAN class=420542514-13042011>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesSt<SPAN 
class=420542514-13042011>op</SPAN>(&nbsp;<SPAN 
class=420542514-13042011>"Step1-1</SPAN>&nbsp;)</FONT></P></SPAN>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesStart(&nbsp;<SPAN 
class=420542514-13042011>"Step1-2</SPAN>&nbsp;)</FONT></P>
<P><SPAN class=420542514-13042011><FONT color=#808080 size=2 face=Verdana>do 
something</FONT></SPAN></P><SPAN class=420542514-13042011>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesSt<SPAN 
class=420542514-13042011>op</SPAN>(&nbsp;<SPAN 
class=420542514-13042011>"Step1-2</SPAN>&nbsp;)</FONT></P>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesSt<SPAN 
class=420542514-13042011>op</SPAN>(&nbsp;<SPAN 
class=420542514-13042011>"Step1</SPAN>&nbsp;)</FONT></P></SPAN>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesStart(&nbsp;<SPAN 
class=420542514-13042011>"Step2"</SPAN>)</FONT></P>
<P><FONT color=#808080 size=2 face=Verdana>itkProbesSt<SPAN 
class=420542514-13042011>op</SPAN>(&nbsp;<SPAN 
class=420542514-13042011>"Step2"</SPAN>)</FONT></P></SPAN></FONT>
<P><FONT size=2><SPAN 
class=420542514-13042011>itkProbesReport(std::cout);</SPAN></FONT></P></FONT></FONT></SPAN></FONT></FONT></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2 face=Verdana></FONT>&nbsp;</DIV>
<DIV><FONT color=#808080 size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#808080 size=2></FONT>&nbsp;</DIV>
<DIV><BR></DIV>
<DIV dir=ltr lang=de class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>Von:</B> insight-users-bounces@itk.org 
[mailto:insight-users-bounces@itk.org] <B>Im Auftrag von </B>Melanie 
Uks<BR><B>Gesendet:</B> Mittwoch, 13. April 2011 16:25<BR><B>An:</B> 
insight-users@itk.org<BR><B>Betreff:</B> Re: [Insight-users] Memory 
problem<BR></FONT><BR></DIV>
<DIV></DIV>Thanks for your replies.<BR><BR>Neil, I splitted the image and 
repeated the process (see the code at the end of my e-mail). The strange thing I 
totally don't understand is why the processing is working when I run just this 
processing in a separate programm and not when I include the processing as a 
"function" in my acutal program.In the separate program it is just working when 
I split the image in 4 parts.<BR><BR>Gerald, I used now for every filter: 
filter-&gt;SetReleaseDataFlag(true);<BR>There was no difference... unfortunately 
:-(<BR><BR><BR>
<DIV class=gmail_quote>2011/4/13 Lodron, Gerald <SPAN dir=ltr>&lt;<A 
href="mailto:Gerald.Lodron@joanneum.at">Gerald.Lodron@joanneum.at</A>&gt;</SPAN><BR>
<BLOCKQUOTE 
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
class=gmail_quote>
  <DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 face=Verdana>itk uses 
  pipelining which means that there is one image in memory after each filtering. 
  So when you have</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana>-&gt;image-&gt;filter1-&gt;filter2-&gt;filter3</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 face=Verdana>you get 
  the memory of the image 4 times. If you want to release the memory after each 
  filter step you can use the release data flag of each filter 
  (SetReleaseDataFlagOn). Then you hage the memory only one 
  time</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 face=Verdana>If you 
  have an image of 300x300x512x3 with float (4 byte) you have 527 MB memory per 
  image, windows 32 theoretically only allows propgramms 2GB (in my tests this 
  theoretically is 1.2 GB in practice) so you only can have the image stored 
  into two vairables, in the third time the allocation will 
  fail!</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 face=Verdana>Another 
  solution is to use the RequestedRegion instead of largestpossibleregion but 
  this is not supported for all filters. here only a part of an image is loaded 
  and processed...I have no experience with this</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2 
  face=Verdana></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN></SPAN><SPAN><FONT color=#0000ff size=2 
  face=Verdana>best regards</FONT></SPAN></DIV><BR>
  <DIV dir=ltr lang=de align=left>
  <HR>
  <FONT size=2 face=Tahoma><B>Von:</B> <A 
  href="mailto:insight-users-bounces@itk.org" 
  target=_blank>insight-users-bounces@itk.org</A> [mailto:<A 
  href="mailto:insight-users-bounces@itk.org" 
  target=_blank>insight-users-bounces@itk.org</A>] <B>Im Auftrag von </B>Melanie 
  Uks<BR><B>Gesendet:</B> Mittwoch, 13. April 2011 15:34<BR><B>An:</B> <A 
  href="mailto:insight-users@itk.org" 
  target=_blank>insight-users@itk.org</A><BR><B>Betreff:</B> Re: [Insight-users] 
  Memory problem<BR></FONT><BR></DIV>
  <DIV>
  <DIV></DIV>
  <DIV class=h5>
  <DIV></DIV>Sorry, I don't have that much expertice: what does "individual 
  chunks" mean and how to implement?<BR><BR>
  <DIV class=gmail_quote>2011/4/13 Neil Panjwani <SPAN dir=ltr>&lt;<A 
  href="mailto:paniwani@gmail.com" 
  target=_blank>paniwani@gmail.com</A>&gt;</SPAN><BR>
  <BLOCKQUOTE 
  style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
  class=gmail_quote>I had similar memory allocation problems when running 
    several CT slices in 32 bit. If you can, using 64-bit should solve your 
    memory problems. 
    <DIV><BR></DIV>
    <DIV>Otherwise, I think you'd have to apply your algorithm on individual 
    chunks at a time and combine them at the end. 
    <DIV>
    <DIV></DIV>
    <DIV><BR><BR>
    <DIV class=gmail_quote>On Wed, Apr 13, 2011 at 9:22 AM, Melanie Uks <SPAN 
    dir=ltr>&lt;<A href="mailto:meluks2010@googlemail.com" 
    target=_blank>meluks2010@googlemail.com</A>&gt;</SPAN> wrote:<BR>
    <BLOCKQUOTE 
    style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
    class=gmail_quote>I am running 32 bit. 
      <DIV>
      <DIV></DIV>
      <DIV><BR><BR>
      <DIV class=gmail_quote>2011/4/13 Neil Panjwani <SPAN dir=ltr>&lt;<A 
      href="mailto:paniwani@gmail.com" 
      target=_blank>paniwani@gmail.com</A>&gt;</SPAN><BR>
      <BLOCKQUOTE 
      style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
      class=gmail_quote>Are you running in 32 or 64 bit?<BR><BR>
        <DIV class=gmail_quote>
        <DIV>
        <DIV></DIV>
        <DIV>On Wed, Apr 13, 2011 at 4:47 AM, Melanie Uks <SPAN dir=ltr>&lt;<A 
        href="mailto:meluks2010@googlemail.com" 
        target=_blank>meluks2010@googlemail.com</A>&gt;</SPAN> 
        wrote:<BR></DIV></DIV>
        <BLOCKQUOTE 
        style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
        class=gmail_quote>
          <DIV>
          <DIV></DIV>
          <DIV>Hi all,<BR><BR>I tried to filter a 3D image (300x300x512) with 
          the CannyEdgeFilter. I had the problem that I could not allocate the 
          memory for the filtering. Anyway I don't like the CannyEdgeFilter 
          Implementation as one has to guess which values to take for the 
          thresholding before the gradientmagnitude image exists... Therefore I 
          wanted to write my own edge detection routine.<BR><BR>The steps:<BR>I 
          generate a image (size: 300x300x512)<BR>I generate a vector image 
          (size: 300x300x512, vector dimension:3)<BR>a) I split the image, 
          process the imagepart with GradientRecursiveGaussianImageFilter<BR>b) 
          I paste the processed imagepart in the vector image with the 
          PasteImageFilter<BR>I repeat a) and b) until the whole image is 
          processed<BR><BR>Now the first question: Why can't I process the 
          complete image. I have to split the image and get a result... This is 
          the error I get:<BR><FONT size=1><I>itk::ExceptionObject 
          (0151C728)<BR>Location: "class itk::CovariantVector&lt;float,3&gt; 
          *__thiscall itk::ImportImageConta<BR>iner&lt;unsigned long,class 
          itk::CovariantVector&lt;float,3&gt; 
          &gt;::AllocateElements(unsig<BR>ned long) const"<BR>File: 
          h:\itk\insighttoolkit-3.16.0\code\common\itkImportImageContainer.txx<BR>Line: 
          188<BR>Description: Failed to allocate memory for 
          image.</I></FONT><BR><BR>Ok, if I accept that I have to split the 
          image, I have a second question: I was able to run my example programm 
          (code at the end of this mail). Then I copied the code into my actual 
          program. It is a programm with several itk functions and Qt GUI. The 
          only difference is that the image is saved as global variable. I was 
          not able to run the processing. I always had the memory error. 
          Why???<BR><BR>Here now the code for the example 
          processing:<BR><BR>edgetest.cxx<BR><BR><FONT size=1>#include 
          "conio.h"<BR><BR>#include "itkImageFileWriter.h"<BR>#include 
          "itkImageFileReader.h"<BR>#include 
          "itkRegionOfInterestImageFilter.h"<BR>#include 
          "itkGradientRecursiveGaussianImageFilter.h"<BR>#include 
          "itkGradientToMagnitudeImageFilter.h"<BR>#include 
          "itkPasteImageFilter.h"<BR>#include "itkImage.h"<BR><BR>int main(int 
          argc, char* argv[])<BR>{&nbsp; <BR>&nbsp;&nbsp; // Verify number of 
          parameters in command line<BR>&nbsp; // if( argc &lt; 3 
          )<BR>&nbsp;&nbsp;&nbsp; // {<BR>&nbsp;&nbsp;&nbsp; // std::cerr 
          &lt;&lt; "Usage: " &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; // 
          std::cerr &lt;&lt; argv[0] &lt;&lt; " inputImageFile&nbsp; 
          outputVectorImageFile " &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; // 
          return EXIT_FAILURE;<BR>&nbsp;&nbsp;&nbsp; // }<BR>&nbsp; typedef 
          float&nbsp;&nbsp; PixelType;<BR>&nbsp; typedef float&nbsp;&nbsp; 
          ComponentType;<BR>&nbsp; static const unsigned int Dimension = 
          3;<BR>&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt; 
          ImageType;<BR>&nbsp; typedef itk::CovariantVector&lt; ComponentType, 
          <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dimension&nbsp; 
          &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputPixelType;<BR>&nbsp; typedef 
          itk::Image&lt; OutputPixelType, Dimension &gt;&nbsp;&nbsp;&nbsp; 
          OutputImageType;<BR><BR><BR>&nbsp; ImageType::Pointer image = 
          ImageType::New();<BR><BR>&nbsp; ImageType::IndexType start;<BR>&nbsp; 
          for(int i = 0; i &lt; Dimension; i++)<BR>&nbsp;&nbsp;&nbsp; 
          start[i]=0;<BR><BR>&nbsp; ImageType::SizeType size;<BR>&nbsp; size[0] 
          = 300;<BR>&nbsp; size[1] = 300;<BR>&nbsp; size[2] = 512;<BR>&nbsp; 
          <BR>&nbsp; ImageType::RegionType region;<BR>&nbsp; 
          region.SetSize(size);<BR>&nbsp; region.SetIndex(start);<BR>&nbsp; 
          <BR>&nbsp; ImageType::SpacingType spacing;<BR>&nbsp; spacing[0] = 
          20;<BR>&nbsp; spacing[1] = 20;<BR>&nbsp; spacing[2] = 
          4.00493;<BR>&nbsp; <BR>&nbsp; image-&gt;SetRegions(region);<BR>&nbsp; 
          image-&gt;SetSpacing(spacing);<BR>&nbsp; 
          image-&gt;Allocate();<BR><BR>&nbsp; std::cout &lt;&lt; region &lt;&lt; 
          std::endl;<BR><BR>&nbsp; OutputImageType::Pointer vec_image = 
          OutputImageType::New();<BR>&nbsp; OutputImageType::RegionType 
          vecregion;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; OutputImageType::SizeType 
          vecsize;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Size<BR>&nbsp; 
          vecsize[0] = 
          (image-&gt;GetLargestPossibleRegion().GetSize())[0];<BR>&nbsp; 
          vecsize[1] = 
          (image-&gt;GetLargestPossibleRegion().GetSize())[1];<BR>&nbsp; 
          vecsize[2] = 
          (image-&gt;GetLargestPossibleRegion().GetSize())[2];<BR>&nbsp; 
          std::cout&lt;&lt;"size0: "&lt;&lt; vecsize[0]&lt;&lt; " size1: 
          "&lt;&lt; vecsize[1] &lt;&lt; " size2: " &lt;&lt; vecsize[2] 
          &lt;&lt;std::endl;<BR>&nbsp; vecregion.SetSize( vecsize 
          );<BR><BR>&nbsp; OutputImageType::IndexType 
          vecstart;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Start<BR>&nbsp; 
          vecstart[0] = (image-&gt;GetOrigin())[0];<BR>&nbsp; vecstart[1] = 
          (image-&gt;GetOrigin())[1];<BR>&nbsp; vecstart[2] = 
          (image-&gt;GetOrigin())[2];<BR>&nbsp; std::cout&lt;&lt;" start0: 
          "&lt;&lt; vecstart[0]&lt;&lt; " start1: "&lt;&lt; vecstart[1] &lt;&lt; 
          " start2: " &lt;&lt; vecstart[2] &lt;&lt;std::endl;<BR>&nbsp; 
          vecregion.SetIndex( vecstart );<BR>&nbsp; <BR>&nbsp; 
          vec_image-&gt;SetRegions(vecregion);<BR>&nbsp; 
          vec_image-&gt;SetSpacing(image-&gt;GetSpacing());<BR>&nbsp; 
          vec_image-&gt;Allocate();<BR><BR>&nbsp;&nbsp;&nbsp; // The image 
          buffer is initialized to a particular value<BR>&nbsp; 
          OutputImageType::PixelType&nbsp; initialValue;<BR><BR>&nbsp; // A 
          vector can initialize all its components to the<BR>&nbsp; // same 
          value by using the Fill() method.<BR>&nbsp; initialValue.Fill( 0.0 
          );<BR><BR>&nbsp; // Now the image buffer can be initialized with 
          this<BR>&nbsp; // vector value.<BR>&nbsp; vec_image-&gt;FillBuffer( 
          initialValue );<BR>&nbsp; std::cout&lt;&lt; "Allocate" &lt;&lt; 
          std::endl;<BR><BR>&nbsp; typedef itk::RegionOfInterestImageFilter&lt; 
          ImageType, ImageType &gt; ROIFilterType;<BR>&nbsp; 
          ROIFilterType::Pointer roifilter = ROIFilterType::New();<BR><BR>&nbsp; 
          // Number of Regions<BR>&nbsp; int splitcnt_x = 2;<BR>&nbsp; int 
          splitcnt_y = 2;<BR>&nbsp; int overlap = 15;<BR><BR>&nbsp; int 
          stepcnt_x = (int) (size[0]*1.0/splitcnt_x + 0.5);<BR>&nbsp; int 
          stepcnt_y = (int) (size[1]*1.0/splitcnt_y + 0.5);<BR><BR><BR>&nbsp; 
          ImageType::IndexType roistart;<BR>&nbsp; roistart[2]=0;<BR>&nbsp; 
          ImageType::SizeType roisize;<BR>&nbsp; roisize[2]=512;<BR>&nbsp; 
          ImageType::RegionType roiregion;<BR><BR><BR>&nbsp; for (int cnt_x = 0; 
          cnt_x &lt; splitcnt_x; cnt_x++)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; for 
          (int cnt_y = 0; cnt_y &lt; splitcnt_y; cnt_y++)<BR>&nbsp;&nbsp;&nbsp; 
          {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; roistart[0]= 
          cnt_x*stepcnt_x - overlap;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roistart[1]= cnt_y*stepcnt_y - overlap;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; if(cnt_x == 0)<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; roistart[0] = 0;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; roisize[0] = stepcnt_x + 
          overlap;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; roisize[0] = stepcnt_x + 
          2*overlap;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(roisize[0]+roistart[0] 
          &gt; size[0])<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roisize[0] = size[0]-roistart[0];<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(cnt_y 
          == 0)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; roistart[1] = 
          0;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roisize[1] = stepcnt_y + overlap;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          else<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; roisize[1] = stepcnt_y + 
          2*overlap;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(roisize[1]+roistart[1] 
          &gt; size[1])<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roisize[1] = size[1]-roistart[1];<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roiregion.SetSize(roisize);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roiregion.SetIndex(roistart);<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "cnt_x: " &lt;&lt; cnt_x 
          &lt;&lt; " cnt_y: " &lt;&lt; cnt_y &lt;&lt; 
          std::endl;<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cout 
          &lt;&lt; roiregion &lt;&lt; std::endl;<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "ROI region inside image region 
          is " &lt;&lt; region.IsInside(roiregion) &lt;&lt; 
          std::endl;<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          roifilter-&gt;SetRegionOfInterest(roiregion);<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; 
          roifilter-&gt;SetInput(image);<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; //Filter class is 
          instantiated<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef 
          itk::GradientRecursiveGaussianImageFilter&lt;ImageType, 
          OutputImageType&gt; GradFilterType;<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; GradFilterType::Pointer gradfilter = 
          GradFilterType::New();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //sigma is specified in 
          millimeters<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          gradfilter-&gt;SetSigma( 1.5 );&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp; 
          processing pipeline:<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          gradfilter-&gt;SetInput(roifilter-&gt;GetOutput());<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef 
          itk::PasteImageFilter &lt;OutputImageType, OutputImageType &gt; 
          PasteImageFilterType;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // The 
          SetDestinationIndex() method prescribes where in the 
          first<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // input to start 
          pasting data from the second input.<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; // The SetSourceRegion method prescribes the 
          section of the second<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // 
          image to paste into the first.<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          OutputImageType::IndexType destinationIndex;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; destinationIndex[0] = 
          cnt_x*stepcnt_x;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          destinationIndex[1] = cnt_y*stepcnt_y;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; destinationIndex[2] = 0;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          PasteImageFilterType::Pointer pasteFilter = PasteImageFilterType::New 
          ();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          pasteFilter-&gt;SetSourceImage(gradfilter-&gt;GetOutput());<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; 
          pasteFilter-&gt;SetDestinationImage(vec_image);<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          OutputImageType::RegionType pasteregion;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; OutputImageType::IndexType 
          pastestart;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          pastestart[2]=0;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          OutputImageType::SizeType pastesize;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastesize[2]=512;<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastestart[0]= overlap;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastestart[1]= overlap;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastesize[0] = stepcnt_x;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastesize[1] = stepcnt_y;<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; if(cnt_x == 0)<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; pastestart[0] = 0;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(cnt_y 
          == 0)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pastestart[1] = 
          0;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          pasteregion.SetIndex(pastestart);<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; 
          pasteregion.SetSize(pastesize);<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; 
          pasteFilter-&gt;SetSourceRegion(pasteregion);<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; 
          pasteFilter-&gt;SetDestinationIndex(destinationIndex);<BR><BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          pasteFilter-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject 
          &amp; err )<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; 
          std::endl;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          std::cerr &lt;&lt; err &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; 
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 
          EXIT_SUCCESS;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; typedef 
          itk::GradientToMagnitudeImageFilter&lt; OutputImageType, ImageType 
          &gt; MagFilterType;<BR>&nbsp;&nbsp;&nbsp; MagFilterType::Pointer 
          magfilter = MagFilterType::New();<BR><BR>&nbsp;&nbsp;&nbsp; 
          magfilter-&gt;SetInput(vec_image);<BR><BR>&nbsp;&nbsp;&nbsp; 
          try<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          magfilter-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; image 
          = magfilter-&gt;GetOutput();<BR>&nbsp;&nbsp;&nbsp; 
          }<BR>&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err 
          )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; 
          std::endl;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; 
          err &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
          return EXIT_SUCCESS;<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp; 
          }<BR>&nbsp;<BR>&nbsp; getch();<BR>&nbsp; return 
          EXIT_SUCCESS;<BR>}</FONT><BR><BR></DIV></DIV>_____________________________________<BR>Powered 
          by <A href="http://www.kitware.com" 
          target=_blank>www.kitware.com</A><BR><BR>Visit other Kitware 
          open-source projects at<BR><A 
          href="http://www.kitware.com/opensource/opensource.html" 
          target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR><BR>Kitware 
          offers ITK Training Courses, for more information visit:<BR><A 
          href="http://www.kitware.com/products/protraining.html" 
          target=_blank>http://www.kitware.com/products/protraining.html</A><BR><BR>Please 
          keep messages on-topic and check the ITK FAQ at:<BR><A 
          href="http://www.itk.org/Wiki/ITK_FAQ" 
          target=_blank>http://www.itk.org/Wiki/ITK_FAQ</A><BR><BR>Follow this 
          link to subscribe/unsubscribe:<BR><A 
          href="http://www.itk.org/mailman/listinfo/insight-users" 
          target=_blank>http://www.itk.org/mailman/listinfo/insight-users</A><BR><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></DIV><BR></DIV></DIV><BR>_____________________________________<BR>Powered 
      by <A href="http://www.kitware.com" 
      target=_blank>www.kitware.com</A><BR><BR>Visit other Kitware open-source 
      projects at<BR><A href="http://www.kitware.com/opensource/opensource.html" 
      target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR><BR>Kitware 
      offers ITK Training Courses, for more information visit:<BR><A 
      href="http://www.kitware.com/products/protraining.html" 
      target=_blank>http://www.kitware.com/products/protraining.html</A><BR><BR>Please 
      keep messages on-topic and check the ITK FAQ at:<BR><A 
      href="http://www.itk.org/Wiki/ITK_FAQ" 
      target=_blank>http://www.itk.org/Wiki/ITK_FAQ</A><BR><BR>Follow this link 
      to subscribe/unsubscribe:<BR><A 
      href="http://www.itk.org/mailman/listinfo/insight-users" 
      target=_blank>http://www.itk.org/mailman/listinfo/insight-users</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BODY></HTML>