<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Cory,<div><br></div><div>The Convolution filter should expand it's input's requested region, to avoid boundary artifacts between requested regions.</div><div><br></div><div>The output of updating the largest possible region should be the same as when the filter is only updating a ROI. A good test is to check that the output of a full update matches that of when the filter is being driven by the StreamingImageFilter or the ImageFileWriter with a SetNumberOfStreamDivisions to a number.</div><div><br></div><div>Brad</div><div><br><div><div>On Aug 27, 2012, at 11:23 AM, Cory Quammen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Matthias,<br><br>You've uncovered a use-case that no one else has. I'm not too<br>surprised it doesn't work when the image region is smaller than the<br>kernel.<br><br>What would your expectation be if this worked? Would you want the<br>convolution filter to expand the requested region of the image when<br>the kernel is larger? Or would you want to apply the boundary<br>condition to extrapolate values beyond the requested region?<br><br>The first option seems reasonable to me. What do you think?<br><br>Thanks,<br>Cory<br><br>On Mon, Aug 27, 2012 at 9:57 AM, Matthias Schneider<br>&lt;<a href="mailto:schneider@vision.ee.ethz.ch">schneider@vision.ee.ethz.ch</a>&gt; wrote:<br><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I noticed some "strange" behavior of the convolution filter.<br></blockquote><blockquote type="cite">Applying the ConvolutionImageFilter to a small region of interest (ROI) of<br></blockquote><blockquote type="cite">an image seems to work iff the kernel size somehow matches the ROI.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">In the code attached below I use a 100x100x100 voxel image.<br></blockquote><blockquote type="cite">Applying the filter for different kernel sizes and ROI configurations I get<br></blockquote><blockquote type="cite">(kernel size [KS], ROI index [RI], ROI size [RS]):<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">[KS] &nbsp;&nbsp;&nbsp;[RI] &nbsp;&nbsp;&nbsp;[RS] &nbsp;&nbsp;&nbsp;[ERROR]<br></blockquote><blockquote type="cite">5 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OK<br></blockquote><blockquote type="cite">5 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR<br></blockquote><blockquote type="cite">5 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">6 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR<br></blockquote><blockquote type="cite">6 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OK<br></blockquote><blockquote type="cite">6 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OK<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The error look like this, e.g. for the case<br></blockquote><blockquote type="cite">[KS]=5, [RI]=0, [RS]=1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">== BEGIN ERROR MESSAGE ==<br></blockquote><blockquote type="cite">itk::ERROR: MultiThreader(0x1a31350): Exception occurred during<br></blockquote><blockquote type="cite">SingleMethodExecute<br></blockquote><blockquote type="cite">[some<br></blockquote><blockquote type="cite">path]/InsightToolkit-4.1.0/Modules/Core/Common/include/itkImageConstIterator.h:177:<br></blockquote><blockquote type="cite">itk::ERROR: Region ImageRegion (0x7fff61cb7ae0)<br></blockquote><blockquote type="cite"> &nbsp;Dimension: 3<br></blockquote><blockquote type="cite"> &nbsp;Index: [2, 0, 0]<br></blockquote><blockquote type="cite"> &nbsp;Size: [1, 1, 1]<br></blockquote><blockquote type="cite"> is outside of buffered region ImageRegion (0x1a2f770)<br></blockquote><blockquote type="cite"> &nbsp;Dimension: 3<br></blockquote><blockquote type="cite"> &nbsp;Index: [0, 0, 0]<br></blockquote><blockquote type="cite"> &nbsp;Size: [1, 1, 1]<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Aborted<br></blockquote><blockquote type="cite">== END ERROR MESSAGE ==<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">It seems like in this case the condition is something like<br></blockquote><blockquote type="cite">[RI]+[RS] &gt;= floor([KS]/2)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">But I do not fully understand where this might come from?!<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">For the record, I am using ITK 4.1.0 (self-compiled)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any hint/help is appreciated very much!<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks,<br></blockquote><blockquote type="cite">matthias<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">This is the code:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">== BEGIN CODE ==<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">#include &lt;itkConvolutionImageFilter.h&gt;<br></blockquote><blockquote type="cite">#include &lt;itkRegionOfInterestImageFilter.h&gt;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">int main(int argc, char **argv) {<br></blockquote><blockquote type="cite"> &nbsp;typedef itk::Image&lt;double, 3&gt; ImageType;<br></blockquote><blockquote type="cite"> &nbsp;typedef ImageType::RegionType RegionType;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;int kernelSize = atoi(argv[1]);<br></blockquote><blockquote type="cite"> &nbsp;int roiIndex = atoi(argv[2]);<br></blockquote><blockquote type="cite"> &nbsp;int roiSize = atoi(argv[3]);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// set up image regions<br></blockquote><blockquote type="cite"> &nbsp;RegionType imageRegion, kernelRegion, roi;<br></blockquote><blockquote type="cite"> &nbsp;for (unsigned int i = 0; i &lt; ImageType::ImageDimension; ++i) {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;imageRegion.SetSize(i, 100);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;kernelRegion.SetSize(i, kernelSize);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;roi.SetSize(i, roiSize);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;roi.SetIndex(i, roiIndex);<br></blockquote><blockquote type="cite"> &nbsp;}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// allocate test image<br></blockquote><blockquote type="cite"> &nbsp;ImageType::Pointer image = ImageType::New();<br></blockquote><blockquote type="cite"> &nbsp;image-&gt;SetRegions(imageRegion);<br></blockquote><blockquote type="cite"> &nbsp;image-&gt;Allocate();<br></blockquote><blockquote type="cite"> &nbsp;image-&gt;FillBuffer(1.0);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// allocate kernel<br></blockquote><blockquote type="cite"> &nbsp;ImageType::Pointer kernel = ImageType::New();<br></blockquote><blockquote type="cite"> &nbsp;kernel-&gt;SetRegions(kernelRegion);<br></blockquote><blockquote type="cite"> &nbsp;kernel-&gt;Allocate();<br></blockquote><blockquote type="cite"> &nbsp;kernel-&gt;FillBuffer(1.0);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// set up convolution<br></blockquote><blockquote type="cite"> &nbsp;typedef itk::ConvolutionImageFilter&lt;ImageType&gt; FilterType;<br></blockquote><blockquote type="cite"> &nbsp;FilterType::Pointer conv = FilterType::New();<br></blockquote><blockquote type="cite"> &nbsp;conv-&gt;SetOutputRegionModeToSame();<br></blockquote><blockquote type="cite"> &nbsp;conv-&gt;SetInput(image);<br></blockquote><blockquote type="cite"> &nbsp;conv-&gt;SetKernelImage(kernel);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// extract region of interest<br></blockquote><blockquote type="cite"> &nbsp;typedef itk::RegionOfInterestImageFilter&lt;ImageType, ImageType&gt;<br></blockquote><blockquote type="cite">ExtractorFilterType;<br></blockquote><blockquote type="cite"> &nbsp;ExtractorFilterType::Pointer extractor = ExtractorFilterType::New();<br></blockquote><blockquote type="cite"> &nbsp;extractor-&gt;SetInput(conv-&gt;GetOutput());<br></blockquote><blockquote type="cite"> &nbsp;extractor-&gt;SetRegionOfInterest(roi);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;// run pipeline<br></blockquote><blockquote type="cite"> &nbsp;extractor-&gt;Update();<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;/* NOTE: Skipping the RegionOfInterestImageFilter and directly<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;* setting the ROI on the convolution filter output results in the<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;* same behavior<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;* [...]<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;* conv-&gt;GetOutput()-&gt;SetRequestedRegion(roi);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;* conv-&gt;Update();<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;*/<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;return 1;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">== END CODE ==<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">--<br></blockquote><blockquote type="cite">Matthias Schneider<br></blockquote><blockquote type="cite">Computer Vision Laboratory<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">ETH Zürich, ETF D114.1<br></blockquote><blockquote type="cite">Sternwartstrasse 7<br></blockquote><blockquote type="cite">8092 Zürich, Switzerland<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">fon: +41 44 63 20379<br></blockquote><blockquote type="cite">fax: +41 44 63 21199<br></blockquote><blockquote type="cite"><a href="http://www.vision.ee.ethz.ch/~schneima/">www.vision.ee.ethz.ch/~schneima/</a><br></blockquote><blockquote type="cite">_____________________________________<br></blockquote><blockquote type="cite">Powered by <a href="http://www.kitware.com">www.kitware.com</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Visit other Kitware open-source projects at<br></blockquote><blockquote type="cite"><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Kitware offers ITK Training Courses, for more information visit:<br></blockquote><blockquote type="cite"><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Please keep messages on-topic and check the ITK FAQ at:<br></blockquote><blockquote type="cite"><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Follow this link to subscribe/unsubscribe:<br></blockquote><blockquote type="cite"><a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote><br><br><br>-- <br>Cory Quammen<br>Research Associate<br>Department of Computer Science<br>The University of North Carolina at Chapel Hill<br>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>