<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><<a href="mailto:schneider@vision.ee.ethz.ch">schneider@vision.ee.ethz.ch</a>> 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] [RI] [RS] [ERROR]<br></blockquote><blockquote type="cite">5 0 2 OK<br></blockquote><blockquote type="cite">5 0 1 ERROR<br></blockquote><blockquote type="cite">5 1 1 ERROR<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">6 0 2 ERROR<br></blockquote><blockquote type="cite">6 0 3 OK<br></blockquote><blockquote type="cite">6 1 2 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"> Dimension: 3<br></blockquote><blockquote type="cite"> Index: [2, 0, 0]<br></blockquote><blockquote type="cite"> Size: [1, 1, 1]<br></blockquote><blockquote type="cite"> is outside of buffered region ImageRegion (0x1a2f770)<br></blockquote><blockquote type="cite"> Dimension: 3<br></blockquote><blockquote type="cite"> Index: [0, 0, 0]<br></blockquote><blockquote type="cite"> 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] >= 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 <itkConvolutionImageFilter.h><br></blockquote><blockquote type="cite">#include <itkRegionOfInterestImageFilter.h><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">int main(int argc, char **argv) {<br></blockquote><blockquote type="cite"> typedef itk::Image<double, 3> ImageType;<br></blockquote><blockquote type="cite"> typedef ImageType::RegionType RegionType;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> int kernelSize = atoi(argv[1]);<br></blockquote><blockquote type="cite"> int roiIndex = atoi(argv[2]);<br></blockquote><blockquote type="cite"> int roiSize = atoi(argv[3]);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // set up image regions<br></blockquote><blockquote type="cite"> RegionType imageRegion, kernelRegion, roi;<br></blockquote><blockquote type="cite"> for (unsigned int i = 0; i < ImageType::ImageDimension; ++i) {<br></blockquote><blockquote type="cite"> imageRegion.SetSize(i, 100);<br></blockquote><blockquote type="cite"> kernelRegion.SetSize(i, kernelSize);<br></blockquote><blockquote type="cite"> roi.SetSize(i, roiSize);<br></blockquote><blockquote type="cite"> roi.SetIndex(i, roiIndex);<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // allocate test image<br></blockquote><blockquote type="cite"> ImageType::Pointer image = ImageType::New();<br></blockquote><blockquote type="cite"> image->SetRegions(imageRegion);<br></blockquote><blockquote type="cite"> image->Allocate();<br></blockquote><blockquote type="cite"> image->FillBuffer(1.0);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // allocate kernel<br></blockquote><blockquote type="cite"> ImageType::Pointer kernel = ImageType::New();<br></blockquote><blockquote type="cite"> kernel->SetRegions(kernelRegion);<br></blockquote><blockquote type="cite"> kernel->Allocate();<br></blockquote><blockquote type="cite"> kernel->FillBuffer(1.0);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // set up convolution<br></blockquote><blockquote type="cite"> typedef itk::ConvolutionImageFilter<ImageType> FilterType;<br></blockquote><blockquote type="cite"> FilterType::Pointer conv = FilterType::New();<br></blockquote><blockquote type="cite"> conv->SetOutputRegionModeToSame();<br></blockquote><blockquote type="cite"> conv->SetInput(image);<br></blockquote><blockquote type="cite"> conv->SetKernelImage(kernel);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // extract region of interest<br></blockquote><blockquote type="cite"> typedef itk::RegionOfInterestImageFilter<ImageType, ImageType><br></blockquote><blockquote type="cite">ExtractorFilterType;<br></blockquote><blockquote type="cite"> ExtractorFilterType::Pointer extractor = ExtractorFilterType::New();<br></blockquote><blockquote type="cite"> extractor->SetInput(conv->GetOutput());<br></blockquote><blockquote type="cite"> extractor->SetRegionOfInterest(roi);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> // run pipeline<br></blockquote><blockquote type="cite"> extractor->Update();<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> /* NOTE: Skipping the RegionOfInterestImageFilter and directly<br></blockquote><blockquote type="cite"> * setting the ROI on the convolution filter output results in the<br></blockquote><blockquote type="cite"> * same behavior<br></blockquote><blockquote type="cite"> * [...]<br></blockquote><blockquote type="cite"> * conv->GetOutput()->SetRequestedRegion(roi);<br></blockquote><blockquote type="cite"> * conv->Update();<br></blockquote><blockquote type="cite"> */<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> 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"> </span><span class="Apple-converted-space"> </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"> </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>