[Insight-users] Problem with itkConvolutionImageFilter
Cory Quammen
cquammen at cs.unc.edu
Mon Aug 27 12:40:35 EDT 2012
Okay, I couldn't resist digging into this. I couldn't exactly
replicate you results using v4.1.0. My results were the same as yours
except for [KS]=5, [RI]=1, [RS]=1, which was OK.
Updating to git master, all your tests are OK. There must have been a
change since v4.1.0 that fixes handling of the requested region.
Give that a try and see if you have the same results as me.
Cory
On Mon, Aug 27, 2012 at 9:57 AM, Matthias Schneider
<schneider at vision.ee.ethz.ch> wrote:
> Hi,
>
> I noticed some "strange" behavior of the convolution filter.
> Applying the ConvolutionImageFilter to a small region of interest (ROI) of
> an image seems to work iff the kernel size somehow matches the ROI.
>
> In the code attached below I use a 100x100x100 voxel image.
> Applying the filter for different kernel sizes and ROI configurations I get
> (kernel size [KS], ROI index [RI], ROI size [RS]):
>
> [KS] [RI] [RS] [ERROR]
> 5 0 2 OK
> 5 0 1 ERROR
> 5 1 1 ERROR
>
> 6 0 2 ERROR
> 6 0 3 OK
> 6 1 2 OK
>
> The error look like this, e.g. for the case
> [KS]=5, [RI]=0, [RS]=1
>
> == BEGIN ERROR MESSAGE ==
> itk::ERROR: MultiThreader(0x1a31350): Exception occurred during
> SingleMethodExecute
> [some
> path]/InsightToolkit-4.1.0/Modules/Core/Common/include/itkImageConstIterator.h:177:
> itk::ERROR: Region ImageRegion (0x7fff61cb7ae0)
> Dimension: 3
> Index: [2, 0, 0]
> Size: [1, 1, 1]
> is outside of buffered region ImageRegion (0x1a2f770)
> Dimension: 3
> Index: [0, 0, 0]
> Size: [1, 1, 1]
>
> Aborted
> == END ERROR MESSAGE ==
>
> It seems like in this case the condition is something like
> [RI]+[RS] >= floor([KS]/2)
>
> But I do not fully understand where this might come from?!
>
> For the record, I am using ITK 4.1.0 (self-compiled)
>
> Any hint/help is appreciated very much!
>
> Thanks,
> matthias
>
>
>
> This is the code:
>
> == BEGIN CODE ==
>
> #include <itkConvolutionImageFilter.h>
> #include <itkRegionOfInterestImageFilter.h>
>
> int main(int argc, char **argv) {
> typedef itk::Image<double, 3> ImageType;
> typedef ImageType::RegionType RegionType;
>
> int kernelSize = atoi(argv[1]);
> int roiIndex = atoi(argv[2]);
> int roiSize = atoi(argv[3]);
>
> // set up image regions
> RegionType imageRegion, kernelRegion, roi;
> for (unsigned int i = 0; i < ImageType::ImageDimension; ++i) {
> imageRegion.SetSize(i, 100);
> kernelRegion.SetSize(i, kernelSize);
> roi.SetSize(i, roiSize);
> roi.SetIndex(i, roiIndex);
> }
>
> // allocate test image
> ImageType::Pointer image = ImageType::New();
> image->SetRegions(imageRegion);
> image->Allocate();
> image->FillBuffer(1.0);
>
> // allocate kernel
> ImageType::Pointer kernel = ImageType::New();
> kernel->SetRegions(kernelRegion);
> kernel->Allocate();
> kernel->FillBuffer(1.0);
>
> // set up convolution
> typedef itk::ConvolutionImageFilter<ImageType> FilterType;
> FilterType::Pointer conv = FilterType::New();
> conv->SetOutputRegionModeToSame();
> conv->SetInput(image);
> conv->SetKernelImage(kernel);
>
> // extract region of interest
> typedef itk::RegionOfInterestImageFilter<ImageType, ImageType>
> ExtractorFilterType;
> ExtractorFilterType::Pointer extractor = ExtractorFilterType::New();
> extractor->SetInput(conv->GetOutput());
> extractor->SetRegionOfInterest(roi);
>
> // run pipeline
> extractor->Update();
>
> /* NOTE: Skipping the RegionOfInterestImageFilter and directly
> * setting the ROI on the convolution filter output results in the
> * same behavior
> * [...]
> * conv->GetOutput()->SetRequestedRegion(roi);
> * conv->Update();
> */
>
> return 1;
> }
>
> == END CODE ==
>
> --
> Matthias Schneider
> Computer Vision Laboratory
>
> ETH Zürich, ETF D114.1
> Sternwartstrasse 7
> 8092 Zürich, Switzerland
>
> fon: +41 44 63 20379
> fax: +41 44 63 21199
> www.vision.ee.ethz.ch/~schneima/
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
--
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill
More information about the Insight-users
mailing list